The answer to this is probably "no", but I just wanted to make sure... (also, I'm not trying to get into the whole "gotos are evil" debate :)).

Basically, one of the things that irritates me in my current workflow, is that eventually I get to a point where I'm on page 34, and there are a ton of images in the previous 33 pages; so if I get stuck with something on page 34, requiring multiple texing, I have to wait for all of the 33 pages to get done texing first (and this can take a while), before I can see the results of interest.

So I thought, it would have been awesome, if LaTeX (rather, for me currently, pdflatex) supported a sort of a "jump" or "goto" command, which I could use like this:



% ...

% probably something like this would be needed - pseudo:


% at this point, I'm not interested in the content from 
% start to page 33 - so I'm issuing a jump command 
% right at the document start:


% here content of skipped pages 

% ...

% here is the label, the tex processor  
% should jump to, and continue from:


\section{My page 34 section}

Here there is some content that I'm texing:

A test: \problemcommand


% here is end of the snippet that I care about texing at the moment;
% don't need a jump here - can just use \stop etc to exit prematurely:


% here content continues, to end of doc;
% but I won't be seeing it in PDF, as I issued 
% \stop just previously: 

\section{My page 45 section}

Here some more content, which I'll eventually tex - but not now...



Well, I guess the code speaks for itself - the desired output would be a PDF with the content, corresponding to pg 34-44 of the original document. Obviously page numbers, and page and some of the other (section, equation, etc.) references will not be available/working when doing this kind of "jump"-shortened run, but that is understood without saying; the goal of this is more-less to assist with troublesome snippets in large documents, without the need (or despite it) to separate content in section files, and then commenting the \input lines selectively.

Anything like that within the pdflatex world?

  • 7
    Well, it is not precisely what you want to achieve, but what about the \includeonly command? – user31729 Feb 20 '14 at 6:43
  • 1
    I am also no enlighted by splitting into files, otherwise, I have no other idea about goto commands within LaTeX in order to 'omit' some text not relevant for current editing – user31729 Feb 20 '14 at 7:56
  • 3
    Use the comment package. – Ulrike Fischer Feb 20 '14 at 7:59
  • 1
    @Christian the other problem with \includeonly is that it works on \include, and therefore the file to be \included is surrounded by page breaks, meaning that you would need to comment out a document part (chapter probably) that aligns with the document structure when this is rarely what's needed. I'm sure you know this, but wanted to present the flip side to your useful suggestion. – Chris H Feb 20 '14 at 10:12
  • 1
    @ChrisH: Yes, I know, there is a pagebreak, but I recently learned from another user that there is package newclude preventing the newpage. See one of my recent answers, I can't link it at the moment, it is something called 'dividing into files' – user31729 Feb 20 '14 at 10:15

I would load the comment package and use its comment environment.

Place all the code you want to exclude inside the comment environment, that is replace \JumpGoto{\myjumplabelA} with \begin{comment} and \myjumplabelA with \end{comment}.




\usepackage{lipsum} % only for the example


This is printed.

This is not printed


\section{My page 34 section}

Here there is some content that I'm texing:



enter image description here

If you then want to print what is inside the comment environment you just have to add the line

  • Many thanks for the answer @karlkoeller - I was a bit afraid of comment because of the effect of opening and closing environments, but I just tried it, it works. Two things: don't break environments' nesting (e.g. \begin{itemize} \item{x} \begin{comment} ... \end{itemize} ... \begin{itemize} \item{y} \end{comment} \item{z} \end{itemize} will fail); don't change \begin{ to \includecomment{ (fails) - as post says, add \includecomment{ before \begin{comment}. Thanks again - cheers! – sdaau Feb 20 '14 at 12:32
  • 2
    @sdaau: is that fantasy nesting of environments going to work anywhere? -- it's surely not a special constraint of comment.sty – wasteofspace Feb 20 '14 at 13:08

You can use a verbbox to stuff unwanted content into a verbatim box (that is not typeset). To undo it, comment out the \begine{verbbox} and \end{verbbox} commands. Note from the output, though, that the commented comment is as if it never existed, including section divisions, etc.


enter image description here

  • Many thanks for the answer, @StevenBSegletes - never heard of verbbox before, good to know about it. Cheers! – sdaau Feb 20 '14 at 12:33

Nobody seems to know the package ifthen! Example:

%or: \newcommand{\optionaltext}{0}%
My mandatory text.
  Optional line 1.
  Optional line 2.
Further mandatory text.
  • 2
    That's because the package has been deprecated (if memory serves) :) – Sean Allred Apr 20 '15 at 12:37
  • Why not use the standard TeX \if\else\fi commands in this instance, though? Ends up being much clearer IMO. – Sean Allred Apr 20 '15 at 12:39
  • Oh!! And welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. :) – Sean Allred Apr 20 '15 at 12:40
  • 2
    @SeanAllred Not deprecated, just that many people prefer to use the expandable logic in etoolbox. – Joseph Wright Apr 20 '15 at 12:42
  • @JosephWright I suppose memory does not serve me today :) – Sean Allred Apr 20 '15 at 12:43

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.