独立多环境与 \newlstenvironment

独立多环境与 \newlstenvironment

大概是由于处理的副作用verbatim,该listings软件包提供了\newlstenvironment。不幸的是,生成的环境无法与standalone的多选项配合使用。

可以通过删除\standaloneenv{maxpage}或替换(失去逐字效果)\newlstenvironment来运行以下内容。\newenvironment

\documentclass{standalone}
\usepackage{listings}
\lstset{aboveskip=0pt,belowskip=0pt}

\lstnewenvironment{maxpage}{\setbox0=\hbox\bgroup}{\egroup\usebox0}
\standaloneenv{maxpage}% or [multi=maxpage]

\begin{document}
\begin{maxpage}
This is a test. 
\textbullet $\sin x^2$
And it has more than one line.
In fact, it goes on and on and on and on and on and on and on until is extends quite far.
\end{maxpage}
\end{document}

有没有办法让两者协同工作?

答案1

人们总是可以使用两个环境,一个用于逐字,一个用于多重。

\documentclass[multi=wrapper]{standalone}
\usepackage{listings}
\lstset{aboveskip=0pt,belowskip=0pt}

\newenvironment{wrapper}{}{}
\lstnewenvironment{maxpage}{\setbox0=\hbox\bgroup}{\egroup\usebox0}

\begin{document}
\begin{wrapper}
\begin{maxpage}
This is a test. 
\textbullet $\sin x^2$
And it has more than one line.
In fact, it goes on and on and on and on and on and on and on until is extends quite far.
\end{maxpage}
\end{wrapper}
\end{document}

相关内容