Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Conditional text in LaTeX??

4 views
Skip to first unread message

Ken Poppleton

unread,
Apr 11, 1995, 3:00:00 AM4/11/95
to

Is there a macro package which will work with LaTeX to allow
conditionally included text in a LaTeX document? Or what would the
TeX code be to perform this task? What I would like
is a set of LaTeX commands of the form...

\newconditional{conditionalName}[value]

which would define a new conditional variable 'conditionaName' set to the
optional value. Value would be either \True or \False

\setconditional{conditionalName}{value}

Set a conditional to a value. Value could be either \True or \False.

\begin{conditionalName}
some latex text...
\end{conditionalName}

This would only include the text between the \begin and \end if the
conditional is set to \True.

I currently do not understand enough of raw TeX to create this my self so
any assistance would be helpful...

Thanks in advance
Ken Poppleton
--
-----------------------------------------------------------------------
Ken Poppleton
kpo...@imp.sim.es.com
-----------------------------------------------------------------------

Boris A. Veytsman

unread,
Apr 11, 1995, 3:00:00 AM4/11/95
to
In article <3mec4k$9...@imp.sim.es.com>, kpo...@imp.sim.es.com (Ken Poppleton)
says:

>
>Is there a macro package which will work with LaTeX to allow
>conditionally included text in a LaTeX document? Or what would the
>TeX code be to perform this task? What I would like
>is a set of LaTeX commands of the form...
>
>\newconditional{conditionalName}[value]
>
>which would define a new conditional variable 'conditionaName' set to the
>optional value. Value would be either \True or \False
>
>\setconditional{conditionalName}{value}
>
>Set a conditional to a value. Value could be either \True or \False.
>
>\begin{conditionalName}
> some latex text...
>\end{conditionalName}
>
>This would only include the text between the \begin and \end if the
>conditional is set to \True.
>
>I currently do not understand enough of raw TeX to create this my self so
>any assistance would be helpful...
>


The ifthen package does this. Include in your file the line
\usepackage{ifthen}
Then set your variable to true or false by
\newcommand{\condition}{true} or \newcommand{\condition}{false}.

Then you can use the following statement:

\ifthenelse{\equal{\condition}{true}}{
blah-blah %this is printed iff \condition is set to true
}
{
another blah-blah %this is printed otherwise
}

Good luck

-Boris

Thomas R. Scavo

unread,
Apr 12, 1995, 3:00:00 AM4/12/95
to
In article <3mec4k$9...@imp.sim.es.com>,

Ken Poppleton <kpo...@imp.sim.es.com> wrote:
>
>Is there a macro package which will work with LaTeX to allow
>conditionally included text in a LaTeX document? Or what would the
>TeX code be to perform this task?

Here's a portion of a bibliography that typesets journal titles
abbreviated or in full depending on the value of a flag. Maybe
something like this is what you had in mind?

--------------------------cut here--------------------------
\begin{thebibliography}{Kob1891}

\newif\ifabbreviations
% \abbreviationsfalse
\abbreviationstrue

\bibitem[Hal1694]{Halley1694}%
Halley,~Edmund (1694). A new, exact, and easy method of finding the roots
of any equations generally, and that without any previous reduction
(Latin). \ifabbreviations {\sl Philos.\ Trans.\ Roy.\ Soc.\ London\/} \else
{\sl Philosophical Transactions of the Royal Society of London\/} \fi {\bf
18}, 136--148. [English translation: \ifabbreviations {\sl Philos.\ Trans.\
Roy.\ Soc.\ London\/} \else {\sl Philosophical Transactions of the Royal
Society of London\/} \fi (abridged) {\bf 3}, 640--649 (1809).]

\bibitem[Sch1870]{Schroeder1870}%
Schr\"oder,~E.\ (1870). On infinitely many algorithms for solving
equations (German). \ifabbreviations {\sl Math.\ Ann.\/} \else {\sl
Mathematische Annalen\/} \fi {\bf 2}, 317--365. [English translation by
G.W.~Stewart, TR-92-121, Institute for Advanced Computer Studies,
University of Maryland, College Park, MD, 20742]

\bibitem[Kob1891]{Kobald1891}%
Kobald,~E.\ (1891). Notice concerned with the calculation of roots of
numerical equations (German). \ifabbreviations {\sl Monatsh.\ Math.\ und
Physik\/} \else {\sl Monatshefte f\"ur Mathematik und Physik\/} \fi {\bf 2},
331--332.

\end{thebibliography}
----------------------------cut here-------------------------

Hope this helps,
--
Tom Scavo
trs...@syr.edu

0 new messages