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?


  • 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 9 '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 9 '14 at 14:33
  • see for example tex.stackexchange.com/questions/47576/… – David Carlisle Sep 9 '14 at 14:39
  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
    Debug is set to true 
    Debug is set to false

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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