LaTeX forum ⇒ Text Formattingconditional "code" Topic is solved

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

conditional "code"  Topic is solved

Postby BastienBastien » Wed Aug 09, 2017 5:21 pm

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

  1. #define DETAIL ON
  2.  
  3. if (DETAIL=ON) % in such case we include all the calculation details
  4. {
  5. blablabla
  6. blabla
  7. }


Regards,
Bastien

Tags:

User avatar
thomasb
Posts: 76
Joined: Thu Aug 03, 2017 10:54 am
Location: france

Postby thomasb » Wed Aug 09, 2017 5:23 pm

With etoolbox package, do you need an example ?

BastienBastien
Posts: 36
Joined: Mon Aug 20, 2012 2:27 pm

Postby BastienBastien » Wed Aug 09, 2017 5:48 pm

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

User avatar
thomasb
Posts: 76
Joined: Thu Aug 03, 2017 10:54 am
Location: france

Postby thomasb » Wed Aug 09, 2017 6:10 pm

You can use the boolean either to charge packages, either in the document :
  1. \documentclass{article}
  2. \usepackage{etoolbox}
  3. \newbool{myboolean}
  4. \boolfalse{myboolean}
  5. %\booltrue{myboolean}
  6. \ifbool{myboolean}{
  7. % if
  8. }{
  9. % else
  10. }
  11. \begin{document}
  12. \ifbool{myboolean}{
  13. Text : boolean is true
  14. }{
  15. Text : boolean is false
  16. }
  17. \end{document}


De nada... :P

BastienBastien
Posts: 36
Joined: Mon Aug 20, 2012 2:27 pm

Postby BastienBastien » Fri Aug 11, 2017 5:49 pm

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


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 4 guests