审查词汇表项目

审查词汇表项目

我有一些文档,其中某些文本可能需要隐藏(白色)。文本通常以大块的形式跨越多行。删除的文本需要占用与文本存在时相同的空间。将文本设置为白色是不可接受的。

我已经调查过该censor软件包,但是该xblackout命令无法跨环境起作用,不过此文本包含\gls命令是很常见的。

我已经尝试过下面发布的解决方案:审查多行文本

但是,当遇到词汇表项时,会报告以下错误:

! Package glossaries Error: Glossary entry `{AC}' has not been defined.

似乎\gls需要先扩展,但据我所知,它还\gls不能完全扩展。任何有关审查项目的想法\gls都将不胜感激。

下面提供了 AM(non)WE。

\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}

答案1

概念证明。不受定义影响。

\documentclass{article}
\usepackage{soul}
\usepackage{glossaries}

\makeglossaries
\newacronym{AC}{AC}{Alternating Current}

\makeatletter
\let\glsorig\gls
\DeclareRobustCommand*\secret{%
  \begingroup
    \def\gls##1{\phantom{##1}}%
    \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@%
  \endgroup
}
\newcommand*\restoregls{\let\gls\glsorig}
\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.

\restoregls

\gls{AC}

\printglossary

\end{document}

缺少缩写

答案2

尝试了几种方法后,我发现关键是使用 注册命令soul。在这里,我使用 命令 注册、\gls\ref\cite。看起来第二段中“Foo”之前的空间更大,但希望这是一个简单的修复。\pageref\soulregister

这是一个有效的例子:

\documentclass{article}
\usepackage{soul}
\usepackage{glossaries}

\makeglossaries

\soulregister\cite7
\soulregister\ref7
\soulregister\pageref7
\soulregister\gls7

\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.

\gls{AC}

\printglossary

\end{document}

在此处输入图片描述

相关内容