0

For some reason,

\textbf{\begin{comment}X\end{comment}
Y}

does not compile for me, with various errors. In the following MWE, the error is

File ended while scanning use of \next.

\documentclass{article}
\usepackage{verbatim} 
\begin{document}
Works (X not shown): \begin{comment}X\end{comment}

Works (Y bold): \textbf{%
Y}

Does not compile: \textbf{\begin{comment}X\end{comment}
Y}
\end{document}

Is this supposed not to work, and if so, why?

bers
  • 5,404
  • 2
    You are passing a verbatim environment as a macro parameter. That isn't supposed to work. What do you want to achieve? Bold font for the comment which is not shown? – TeXnician Sep 21 '17 at 08:13
  • @TeXnician I am using the comment environment in latexdiff to hide deleted text. Specifically, when deleting several paragraphs of text, some line breaks always remain even with https://tex.stackexchange.com/a/135947, and I have found no other way to hide those. – bers Sep 21 '17 at 08:25
  • latexdiff --exclude-textcmd="textbf" fixed the concrete problem, but I still wonder why a comment cannot be parsed within \textbf. – bers Sep 21 '17 at 08:31

1 Answers1

2

Workaround:

\documentclass{article}
\usepackage{verbatim} 
\begin{document}

{\bfseries 
\begin{comment}
X
\end{comment} 
Y}

\end{document}