I have some documents where certain text may need to be hidden (whiteout). The text is often in large blocks that span multiple lines. The removed text needs to take up the same space as it would if the text was present. Setting the text to white is not acceptable.
I have investigated the censor
package, but the xblackout
command does not work across environments, but it is common for this text to include \gls
commands.
I have tried the solution below posted here: Censor text spanning multiple lines
However, when a glossary item is encountered, the following error is reported:
! Package glossaries Error: Glossary entry `{AC}' has not been defined.
It seems as if \gls
needs to be first expanded, but my understanding is \gls
is not fully expandable. Any ideas for censoring \gls
items would be greatly appreciated.
A M(non)WE is provided below.
\documentclass{article}
\usepackage{soul}
\usepackage{glossaries}
\makeglossaries
\newacronym{AC}{AC}{Alternating Current}
\makeatletter
\DeclareRobustCommand*\secret{%
\SOUL@setup%
\def\SOUL@everytoken{{\phantom{\the\SOUL@token}}}%
\def\SOUL@everyhyphen{%
\discretionary{%
\SOUL@setkern\SOUL@hyphkern%
\phantom{\SOUL@sethyphenchar}%
}{}{}%
}%
\def\SOUL@everyexhyphen##1{%
\SOUL@setkern\SOUL@hyphkern%
\hbox{\phantom{##1}}%
\discretionary{}{}{%
\SOUL@setkern\SOUL@charkern%
}%
}%
\SOUL@%
}
\makeatother
\begin{document}
This is some text. Some of this text is to be hidden, but the whitespace should be retained. Some of the text to be hidden may include glossary items, such as \gls{AC}. Foo.
\glsresetall
This is some text. \secret{Some of this text is to be hidden, but the whitespace should be retained. Some of the text to be hidden may include glossary items, such as \gls{AC}}. Foo.
\printglossary
\end{document}