Re: trouble with \comment and arguments to \newenvironment
- From: rf@xxxxxxxxxxxx (Robin Fairbairns)
- Date: 15 Sep 2005 21:48:46 GMT
"Bill" <wrising@xxxxxxxxxxxxxx> writes:
>I am confused about the behavior of LaTeX in the following situation.
>It's a bit simplified from what I'm working on, but I've narrowed it
>down the the presence of an optional argument:
>
>This environment works just fine (for block on/off selections of text):
>\newenvironment{answer}{%
>\ifanswer\ifansfont\begin{rmfamily}\fi\else\comment\fi%
>}%
>{%
>\ifanswer\ifansfont\end{rmfamily}\fi\else\endcomment\fi%
>}
>
>Replacing the first line with the following also works just fine, as
>long as I give an argument to each \begin{answer} in the document:
>
>\newenvironment{answer}[1]{% etc...
>
>It keeps working just fine when the first line is the following, once
>again, as long as I give an argument to each \begin{answer}:
>
>\newenvironment{answer}[1][0]{% etc...
>
>If, however, I actually treat the optional argument as optional, by
>having the last specification but a \begin{answer} with no ``optional''
>argument. They are the type of errors that one sees when using \comment
>incorrectly, namely Paragraph ended before \verbatim@ was complete.
i can't replicate that.
>My guess is that the problem comes from LaTeX needing to somehow
>evaluate the block twice when the optional argument is not specified,
>but this seems odd.
it doesn't need to evaluate things twice. look at the definitions of
the commands: they may seem odd, but there ain't no multiple pass.
>Does anyone know of a workaround? The actual environment I'm defining
>is much more complicated than what is given above --- the above is the
>simplest scenario where I could reproduce the error.
but it isn't a complete failing example. filling in a few gaps, i get
something that doesn't fail.
if you want help, you need to develop the above enough that the rest
of us can actually see you failure on our own machines.
--
Robin (http://www.tex.ac.uk/faq) Fairbairns, Cambridge
.
- Follow-Ups:
- Prev by Date: Re: Changebar in PDFLaTeX
- Next by Date: numbering the title page
- Previous by thread: Re: trouble with \comment and arguments to \newenvironment
- Next by thread: Re: trouble with \comment and arguments to \newenvironment
- Index(es):
Relevant Pages
|