A question for the LaTeX gurus (2)

So I’ve sort-of figured out how to do conditional blocks. The following LaTeX initially appears to work:

\newboolean{cond1}
\newboolean{cond2}

\setboolean{cond1}{false}
\setboolean{cond2}{true}

\ifthenelse{\boolean{cond1}}
{
A block of conditional text in here.
blah blah
}

\ifthenelse{\boolean{cond2}}
{
A separate block of conditional text in here.
blah blah
}

I say initially appears to work, because it works fine for the first 4 or 5 attempts, but then some combination of blocks (\begin{verbatim} for example), causes it to break on the 6 attempt. If I include a verbatim block in that 6 attempt, latex outputs an obscure error message… something along the lines of:

Runaway argument?
some code here \end {verbatim} \end {listing}
! Paragraph ended before \@xverbatim was complete.
<to be read again>

Which is rather infuriating, considering that I’ve got verbatim blocks in the previous conditional sections (it doesn’t complain about those), and because I’ve almost got the answer to my problem.

RSS feed | Trackback URI

3 Comments »

Comment by jrbriggs
2008-03-04 11:41:12

Addendum…

Further reading indicates the problem is (rather obviously) using verbatim inside the scope of another command. Though as to why that’s a problem, or how to get around it — I’m not any closer to answering.

 
Comment by jrbriggs
2008-03-04 11:51:23

Gah! Even more infuriating. Found one reference to using \relax after the ifthenelse. Which fixes the problem — but only if you use it on the ifthenelse that is actually firing (i.e. the one set to true). On the others, it breaks. Meaning it’s a no-solution solution.

 
Comment by jrbriggs
2008-03-04 12:12:24

Eureka! Or some other exclamation.

The winner is…

versions.sty

Which I overlooked before for some reason, and revisited, only to discover it’s exactly what I want, and works as advertised. With thanks to Uwe L”uck, for releasing it and relieving 4 days of frustration.

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

Trackback responses to this post