comment package - \excludecomment{} gives error
1,526
Package version
\documentclass[letterpaper]{article}
\usepackage[hmargin=2.5cm,vmargin=3.0cm]{geometry}
\linespread{1.3} % use 1.5 line spacing
\usepackage[pdftex]{graphicx}
\usepackage{lipsum}
\usepackage{wrapfig} % puts the figure wrapped
\newif\ifshow
%\showtrue
\showfalse
\usepackage{version}
\ifshow
\includeversion{wrapfigure}
\else
\excludeversion{wrapfigure}
\fi
\begin{document}
\lipsum[1]
\begin{wrapfigure}{r}{0.5\textwidth}
\begin{center}
\includegraphics[width=0.4\textwidth]{latex.png}
\end{center}
\caption{Caption}
\label{fig:00}
\end{wrapfigure}
\lipsum[2]
\end{document}
Package comment
The environment is an outer shell with its contents is set or is not depending on
\excludeversion
or \includeversion
. Also the environment markers have to be on a line
of their own. \excludeversion
and \includeversion
do not work well with existing environments. \endwrapfigure
causes the error messages. Thus an additional wrapper environment is needed:
\documentclass[letterpaper]{article}
\usepackage[hmargin=2.5cm,vmargin=3.0cm]{geometry}
\linespread{1.3} % use 1.5 line spacing
\usepackage[pdftex]{graphicx}
\usepackage{lipsum}
\usepackage{wrapfig} % puts the figure wrapped
\newif\ifshow
\showtrue
%\showfalse
\usepackage{comment}
\ifshow
\includecomment{wrap}
\else
\excludecomment{wrap}
\fi
\begin{document}
\lipsum[1]
\begin{wrap}
\begin{wrapfigure}{r}{0.5\textwidth}
\begin{center}
\includegraphics[width=0.4\textwidth]{latex.png}
\end{center}
\caption{Caption}
\label{fig:00}
\end{wrapfigure}
\end{wrap}
\lipsum[2]
\end{document}
Related videos on Youtube
Author by
gbc921
Updated on August 01, 2022Comments
-
gbc921 over 1 year
I'm trying to generate a pdf file without the pictures for draft revision, and as seen here and here the
\excludecomment{}
is not working for me.Here is my error:
line 31: Extra }, or forgotten \endgroup \end{wrapfigure} line 31: Undefined control sequence \end{wrapfigure} line 31: Missing number, treated as zero \end{wrapfigure} line 31: Illegal unit of measure (pt inserted) \end{wrapfigure}
given by my test code:
\documentclass[letterpaper]{article} \usepackage[hmargin=2.5cm,vmargin=3.0cm]{geometry} \linespread{1.3} % use 1.5 line spacing \usepackage[pdftex]{graphicx} \usepackage{wrapfig} % puts the figure wrapped \newif\ifshow %\showtrue \showfalse \usepackage{comment} %\excludecomment{itemize} \ifshow \includecomment{wrapfigure} \else \excludecomment{wrapfigure} \fi \excludecomment{wrapfigure} \begin{document} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tempus convallis euismod. Vestibulum aliquet lacus at diam laoreet a scelerisque purus posuere. \begin{wrapfigure}{r}{0.5\textwidth} \begin{center} \includegraphics[width=0.4\textwidth]{latex.png} \end{center} \caption{Caption} \label{fig:00} \end{wrapfigure} \end{document}
Neither using the
\removecomment{}
or theif
sentence works.-
Corentin about 11 yearsWhat about the
[draft]
option for thegraphicx
package? -
Corentin about 11 years..and Welcome to TeX.sx!
-
gbc921 about 11 yearsThanks man! I've used your approach as is really easy to remove the pictures.
-
-
gbc921 about 11 yearsThanks for the answer! The both method worked perfectly! I will mark as solved, however I will follow the comment from @Coretin and use the
[draft]
(or[demo]
) option fromgrapicx
because is simpler, does the job of removing the picture (or the big size of the PDF) and I do not need to edit the code (at least for the comment package). (I should had searched with other terms on Google before getting lost on comment pkg. :D)