🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #480

How to make a macro expand to nothing?

#480
From: Christopher Rath
Date: Mon, 27 Jul 1992 21:30
31 lines
1591 bytes
I am using the following latex macro:

	\newcommand{\Ch}[2]{{#2}}

When used, it produces the following output from the given input:

	input:   This is \Ch{G}{a} sam\Ch{C}{ple.} \Ch{G}{}

	output:  This is a sample.

This works as expected except when the line is very long. If the last
word in a paragraph butts directly against the right margin, then
extra whitespace gets inserted after the paragraph.  I believe this is
because the final "\Ch{G}{}" macro (from the above example) is
actually taking up space instead of disappearing.

In the macro definition, the second parameter is enclosed in braces so
that any font changes remain local to the parameter.  Even if I remove
the extra braces around #2, an empty parameter appears to take up
space.

Can anyone help me out?  How do I make this macro disappear when the
second parameter is left empty?

Thanks,
Christopher
---
 Christopher Rath   | crath@bnr.ca
 BNR Woodline       |
 Ottawa, ON, Canada | "Hydrogen is a colourless, odourless gas which, given 
 (613) 765-3141     | enough time, turns into people." -- Henry Hiebert
Technical Details
Message-ID: <1992Jul27.213015.29910@bmerh85.bnr.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!europa.asd.contel.com!darwin.sura.net!convex!news.utdallas.edu!corpgate!bnrgate!bmerh85!bwdlha!crath

Show Full Headers
Complete Article Headers
Newsgroups: comp.text.tex
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!europa.asd.contel.com!darwin.sura.net!convex!news.utdallas.edu!corpgate!bnrgate!bmerh85!bwdlha!crath
From: crath@BNR.CA (Christopher Rath)
Subject: How to make a macro expand to nothing?
Message-ID: <1992Jul27.213015.29910@bmerh85.bnr.ca>
Keywords: macro latex tex
Sender: news@bmerh85.bnr.ca (Usenet News)
Reply-To: crath@bnr.ca
Organization: BNR Woodline, Ottawa
Date: Mon, 27 Jul 92 21:30:15 GMT
Lines: 31