如何创建包含来自 multiaudience 包的 Showto 的环境?

如何创建包含来自 multiaudience 包的 Showto 的环境?

是否可以创建一个包含包shownto环境的环境multiaudience

使用以下 MWE 我得到了错误! LaTeX Error: \begin{shownto} on input line 26 ended by \end{cmcomment}.

\documentclass{book}
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{multiaudience}
\SetNewAudience{others}
\SetNewAudience{onlyme} 
\DefCurrentAudience{onlyme} 

\newenvironment{cmcomment}{%
    \begin{shownto}{onlyme}\textcolor{gray}\small\singlespacing%
    }{\end{shownto}}

\usepackage{mwe}

\begin{document}
\doublespacing
Everyone read this \blindtext
\begin{cmcomment}
I read this \blindtext
\end{cmcomment}
\end{document}

答案1

除了使用之外,\newenvironment您还可以使用\NewDocumentEnvironment-typeb参数:

\documentclass{book}
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{multiaudience}
\SetNewAudience{others}
\SetNewAudience{onlyme} 
\DefCurrentAudience{onlyme} 

\NewDocumentEnvironment{cmcomment}{+b}
  {%
    \begin{shownto}{onlyme}%
      \color{gray}\small
      \singlespacing%
      #1\par%
    \end{shownto}%
  }
  {}

\NewDocumentEnvironment{otcomment}{+b}
  {%
    \begin{shownto}{others}%
      \color{gray}\small
      \singlespacing
      #1\par
    \end{shownto}%
  }
  {}

\usepackage{mwe}

\begin{document}
\doublespacing
Everyone read this \blindtext

\begin{cmcomment}
I read this \blindtext
\end{cmcomment}

Everyone read this \blindtext
\begin{otcomment}
Others read this \blindtext
\end{otcomment}
\end{document}

相关内容