TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to have some variables for showing or hiding text in Latex.

For example, I would like to have two versions of a document. A short version and a long version by changing a variable at the top of the latex document.

For example:

I want to set a variable long - true

and in the text I would like to use if long == true show text (long version) else if false do not show the text (short version).

Any examples?

share|improve this question
You might like the tagging package, wich was created by one of our users (Brent Longborough), also have a look at this question. – Tom Bombadil Jun 5 '12 at 11:12
use the package comment. It allows to handle different parts of the document. You'll get the documentation with texdoc comment – Herbert Jun 5 '12 at 11:23


  \iflong \lipsum[1] \else short version \fi 

  \iflong \lipsum[1] \else short version \fi 

With ifthen



\ifthenelse{\boolean{long}}{long version}{short version} 

\ifthenelse{\boolean{long}}{long version}{short version}  
share|improve this answer

I second Herbert on using the comment package. :) Here's a possible solution with etoolbox and \iftoggle{<name>}{<true>}{<false>}:





\iftoggle{long}{Overhead the albatross hangs motionless upon the air.}%
{And deep beneath the rolling waves in labyrinths of coral caves.}


There's also \nottoggle{<name>}{<not true>}{<not false>} which negates the test.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.