# Should I be able to insert a comment environment into \textbf?

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?

• 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 8: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 tex.stackexchange.com/a/135947, and I have found no other way to hide those. – bers Sep 21 '17 at 8: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 8:31

Workaround:

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

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

\end{document}