Text Formattingconditional "code"

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
BastienBastien
Posts: 40
Joined: Mon Aug 20, 2012 2:27 pm

conditional "code"

Post by BastienBastien »

Hello,
Do you have an idea how I could make a conditional code inclusion?
Something like that:
#define DETAIL ON

if (DETAIL=ON)     % in such case we include all the calculation details
{
     blablabla
     blabla
}
Regards,
Bastien

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

thomasb
Posts: 134
Joined: Thu Aug 03, 2017 10:54 am

conditional "code"

Post by thomasb »

With etoolbox package, do you need an example ?
BastienBastien
Posts: 40
Joined: Mon Aug 20, 2012 2:27 pm

conditional "code"

Post by BastienBastien »

Hi,
I was about to answer you: no, thanks I can handle it.
But I had a look on the documentation and it seems low level code.
I am definitely not used to.

May be I could use:

ifdefined
undefinded
ifbool
newtoggle
toggletrue
togllefalse
newbool
ifdef
ifundef

but I am realy not sure!
would be great if you can write a couple of code lines suited to the problematic.

Merci Thomas !

Bastien
thomasb
Posts: 134
Joined: Thu Aug 03, 2017 10:54 am

conditional "code"

Post by thomasb »

You can use the boolean either to charge packages, either in the document :

Code: Select all

\documentclass{article}
\usepackage{etoolbox} 
\newbool{myboolean}
\boolfalse{myboolean}
%\booltrue{myboolean} 
\ifbool{myboolean}{  
  % if
}{
  % else  
}
\begin{document} 
\ifbool{myboolean}{
Text : boolean is true
}{
Text : boolean is false
}
\end{document}

De nada... :P
BastienBastien
Posts: 40
Joined: Mon Aug 20, 2012 2:27 pm

conditional "code"

Post by BastienBastien »

Hi,

I confirme it works fine.
Now I have an other problem: it is diffcult to arange the redaction with two versions:
one without the detaIls,
and all details in a conditional code block,
but this is not a LaTeX issue!

Bye
Post Reply