是否可以禁用 mdframed 包显示任何内容

是否可以禁用 mdframed 包显示任何内容

我在起草报告时经常使用该mdframed软件包,主要是通过使用颜色来提醒我注意需要重新处理这些部分。现在我必须发送一份不包含任何需要重新处理的内容的 PDF,但我不想注释掉每个出现的mdframed。是否可以(暂时)禁止“打印”任何mdframed内容?

\begin{mdframed}[hidealllines=true,backgroundcolor=blue!20]
I do not want this content to be printed.
\end{mdframed}

我尝试了以下选项,但没有成功:

\renewenvironment{mdframed}{}{}

\let\mdfsetup\relax\vspace{0pt}
\let\begin{mdframed}\relax\vspace{0pt}
\let\end{mdframed}\relax\vspace{0pt}

答案1

使用当前的 LaTeX,您可以抓住主体然后将其扔掉:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{mdframed}
\RenewDocumentEnvironment{mdframed}{+b}{}{}
\begin{document}

Text before the environment

\begin{mdframed}[hidealllines=true,backgroundcolor=blue!20]
I do not want this content to be printed.
\end{mdframed}

Text after the enviroment
\end{document}

在此处输入图片描述

答案2

您可以使用它(我展示了什么不起作用,并附带步骤,如何实现目标)。

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{mdframed}

\begin{document}

Text before the environment

\begin{mdframed}[hidealllines=true,backgroundcolor=blue!20]
I do not want this content to be printed.
\end{mdframed}

Text after the environment

\renewenvironment{mdframed}{}{} % Doesn't do what we expected (displays options and content)

First trial: 

\begin{mdframed}[hidealllines=true,backgroundcolor=blue!20]
I do not want this content to be printed.
\end{mdframed}

Text after the first trial

\renewenvironment{mdframed}[1][]{}{} % capture the options (one optional argument, by default nothing. Doesn't  what we expected (displays still the content)

Second trial:

\begin{mdframed}[hidealllines=true,backgroundcolor=blue!20]
I do not want this content to be printed.
\end{mdframed}

Text after the second trial

\newsavebox{\mybox} % creates a box to saving the content to display. As we don't uses the saved box, the text from the environment isn't displayed
\renewenvironment{mdframed}[1][]{\begin{lrbox}{\mybox}}{\end{lrbox}} % works yet 

Third trial:

\begin{mdframed}[hidealllines=true,backgroundcolor=blue!20]
I do not want this content to be printed.
\end{mdframed}

Text after the third trial

\end{document}

您将获得:

在此处输入图片描述

相关内容