Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\documentclass{article}

\usepackage{tikz}

% ...

% probably something like this would be needed - pseudo:
\declareGotoMarker{\myjumplabelA}

\begin{document}

% 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:

\JumpGoto{\myjumplabelA}

% here content of skipped pages 

% ...

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

\myjumplabelA

\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:

\stop

% 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...

...

\end{document}

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?

share|improve this question
6  
Well, it is not precisely what you want to achieve, but what about the \includeonly command? –  Christian Hupfer Feb 20 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 –  Christian Hupfer Feb 20 at 7:56
2  
Use the comment package. –  Ulrike Fischer Feb 20 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 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' –  Christian Hupfer Feb 20 at 10:15
show 1 more comment

2 Answers 2

up vote 11 down vote accepted

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}.

MWE

\documentclass{article}

\usepackage{comment}

\usepackage{lipsum} % only for the example

\begin{document}

This is printed.

\begin{comment}
This is not printed

\lipsum[1-15]
\end{comment}

\section{My page 34 section}

Here there is some content that I'm texing:

\end{document} 

Output

enter image description here

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

\includecomment{comment}
share|improve this answer
    
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 at 12:32
1  
@sdaau: is that fantasy nesting of environments going to work anywhere? -- it's surely not a special constraint of comment.sty –  wasteofspace Feb 20 at 13:08
add comment

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.

\documentclass{article}
\usepackage{verbatimbox}
\usepackage{lipsum}
\begin{document}
\section{First}
\begin{verbbox}
\lipsum[1-12]
\section{Second}
\lipsum[1-5]
\end{verbbox}
\section{Third}
\lipsum[1]
\end{document}

enter image description here

share|improve this answer
    
Many thanks for the answer, @StevenBSegletes - never heard of verbbox before, good to know about it. Cheers! –  sdaau Feb 20 at 12:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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