# Use of the comment package

In a .tex document, I'm using the comment package to produce two different versions (let's say : versionA and versionB) of the document. Each version contains different parts (it could be paragraphs, equations,...). If I use \includecomment{versionA}, it will include all the content between \begin{versionA} and \end{versionA}. Now, let's say some of the parts in each version are marked with a *. How can I ask latex to compile only the * parts in one version ?

It may be clearer on the following example. Let's say I have

\documentclass[10pt,a4paper]{article}

\usepackage{comment}
\includecomment{versionA}
\excludecomment{versionB}

\begin{document}

\begin{versionA}

*part1

part2

*part3

\end{versionA}

\begin{versionB}

part1

*part2

\end{versionB}

\end{document}


I would like something which enables me to do : "compile all the content of versionA" or "compile only the content marked with * in versionA" (same for versionB). I hope this is clear!

• Yes that could be a solution but as long as possible, I would like to have only one .tex document. Using \include and \includeonly would imply having multiple .tex documents. – jibounet Aug 20 '13 at 9:25
• You can place \begin{versionC} and \end{versionC} around the parts in the versionA you do not want (the non starred ones) and add \excludecomment{versionC} to your preamble. – Ludovic C. Aug 20 '13 at 9:36
• Do you want to have two separates documents (one with the starred parts of the versionA and one with the starred parts of the versionB) or only one document with all the starred parts? – Ludovic C. Aug 20 '13 at 9:38
• I would like to have only one document. If I follow your advice and add a \begin{versionC} and \end{versionC} around the starred parts, it works fine ! I just didn't think I could have two \includecomment or \excludecomment in the preamble. – jibounet Aug 20 '13 at 9:45

This will allow you to get all (and only) the starred parts of your document I have added some indentation in order to highlight the different groups of version):

\documentclass[10pt,a4paper]{article}
\usepackage{comment}
\includecomment{versionA}
\includecomment{versionB}
\excludecomment{versionC}

\begin{document}

\begin{versionA}
*part1
\begin{versionC}
part2
\end{versionC}
*part3
\end{versionA}

\begin{versionB}
\begin{versionC}
part1
\end{versionC}
*part2
\end{versionB}

\end{document}


This code will allow you to get all the starred parts from the A version (to get the ones from the B version just invert versionA and versionB in the include/excludecomment commands in the preamble):

\documentclass[10pt,a4paper]{article}
\usepackage{comment}
\includecomment{versionA}
\excludecomment{versionB}
\excludecomment{versionC}

\begin{document}

\begin{versionA}
*part1
\begin{versionC}
part2
\end{versionC}
*part3
\end{versionA}

\begin{versionB}
\begin{versionC}
part1
\end{versionC}
*part2
\end{versionB}

\end{document}

• In the second esample I guess that *part2 of the versionB block should be without the star. I tried to change it but less than a 6 characters changes are not allowed – dPol Aug 12 '15 at 15:13