0

In C, we can write something for some part of the code, and give gcc some option for whether we would like to compile that part of code. It saves us from modifying the C code.

In LaTex, is there a similar way for pdflatex?

Thanks.

Tim
  • 5,763
  • Many editors support commenting code by shortcuts. This could be handy. Or you move the line \end{document} to your desired last line. Or you search this side for conditionals, define some rule debugtrue, debugfalse and start your code-blocks with \ifdebug. – LaRiFaRi Sep 09 '14 at 14:29
  • Thanks, do you know the examples for the last method? Alternatively, can we choose to or not to compile a portion of code by specifying only to pdflatex without touching the code again? – Tim Sep 09 '14 at 14:33
  • see for example http://tex.stackexchange.com/questions/47576/combining-ifxetex-and-ifluatex-with-the-logical-or-operation/47588#47588 – David Carlisle Sep 09 '14 at 14:39

1 Answers1

2
  1. Move your \end{document} up to the place where you want to stop compiling
  2. Comment out the block of code, you do not want to compile (the editors do have shortcuts for this)
  3. Define conditionals in order to block parts for whatever you need:

    % arara: pdflatex
    
    \newif\ifdebug
    \documentclass{article}
    
    \debugtrue
    %\debugfalse
    \begin{document}
    \ifdebug
    Debug is set to true 
    \else
    Debug is set to false
    \fi
    \end{document}
    

In order to check for the possible use of PDFLaTeX or others, you should have a look on the packages ifpdf, ifluatex, ifxetex which define such conditionals for you. The command would read \ifpdf ... \else ... \fi and respectively for the others.

LaRiFaRi
  • 43,807