0

How can I select which section I want to compile and which section I do not want to compile? I am using XeLatex to compile the document. Sometimes the text in each section is long and I don't want to comment and uncomment all of the text inside the section every time I run the script. Every time I am running, need to compile different set of sections. It would be easier to have an easy way to do it. Or just comment/uncomment a particular section line instead of comment/uncommenting the whole text inside.

The question here, suggests to break the file in to multiple files and then run the main script (within the main script one can choose the desirable file(s) to compile). However, I am interested to know is it possible to do it within a single file?

\documentclass[a4paper,10pt]{article} 
\usepackage{xunicode,xltxtra,url,parskip}
\usepackage[usenames,dvipsnames]{xcolor} 
\usepackage[big]{layaureo}
\usepackage{hyperref} 
\definecolor{linkcolour}{rgb}{0,0.2,0.6} 
\hypersetup{colorlinks,breaklinks,urlcolor=linkcolour,linkcolor=linkcolour}

\usepackage{titlesec} 
\titleformat{\section}{\Large\scshape\raggedright}{}{0em}{}[\titlerule]
\titlespacing{\section}{0pt}{3pt}{3pt} 

\usepackage{tabularx}           

\begin{document}

\pagestyle{empty} 

\section{Personal Data}

some text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text here


\section{Education}
some text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text here

\section{Work Experience}

some text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text here


\section{Hobbies}
some text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text here

\section{Interests}
some text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text here

\section{Skills}
some text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text here

\section{MISC}
some text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text heresome text here

\end{document}
Jack
  • 175

1 Answers1

2

Probably the cleanest way to do this is separate your long sections into individual files. You would have a .tex file for each section you wish to compile separately. For your example, you'd have some directory that would look like this:

./
../
main.tex
personal_data.tex
education.tex
...
...
misc.tex

Then in your main.tex file you'd have:

% preamble and document definition
\input{personal_data.tex}
\input{education.tex}
...
...
\input{misc.tex}

To exclude some sections from the compilation, you then only need to comment out the single line containing the \input{} command for that file.

 

If you absolutely hate the idea of having multiple files for one output document, you can use the comment package. It allows you to selectively exclude portions of the text you've wrapped in its environment. For example:

\documentclass{article}
\usepackage{comment}

% Comment environment definitions
\includecomment{PersonalData}
\excludecomment{Education}

\begin{document}
    This text will be displayed

\begin{PersonalData}
    This text will NOT be displayed.
\end{PersonalData}

\begin{Education}
    This text will be displayed.
\end{Education}

\end{document}

NOTE: From the package documentation:

The opening and closing commands should appear on a line of their own. No starting spaces, nothing after it. This environment should work with arbitrary amounts of comment, and the comment can be arbitrary text.

Das_Geek
  • 213