繁体   English   中英

在LaTeX中临时更改文档类/重置pdfLaTeX

[英]Temporarily changing document class in LaTeX/resetting pdfLaTeX

如何暂时使pdfLaTeX忘记我已经告诉它的所有内容并从新的文档类开始?

我已经从lshort文档中修改了示例环境:

\newwrite\examplesx@out
\newenvironment{examplesx}{%
  \begingroup% Lets Keep the Changes Local
    \@bsphack
    \immediate\openout \examplesx@out \jobname.exa
    \let\do\@makeother\dospecials\catcode`\^^M\active
    \def\verbatim@processline{%
      \immediate\write\examplesx@out{\the\verbatim@line}}%
    \verbatim@start
  }{%
  \immediate\closeout\examplesx@out\@esphack\endgroup%
  \noindent\makebox[\textwidth][l]{%
    \begin{minipage}[c]{0.45\textwidth}%
      \small\verbatiminput{\jobname.exa}
    \end{minipage}%
    \hspace*{0.1\textwidth}%
    \framebox{%
      \begin{minipage}{0.45\textwidth}%
        \small\input{\jobname.exa}%
      \end{minipage}
    }%
  }\vspace*{\parskip}%
}

而且大多数情况下都可以,但是我希望能够做类似的事情

\begin{examplesx}
\section{Section}
\end{examplesx}

并将其显示为方框中的一部分。 我也希望它使用标准article样式来排版列表,即使我在beamer使用它也是如此

我认为最简单的方法是编译一些小文档,然后将生成的pdf作为图像包含在较大的文档中。 即使不是您想要的,也要简单得多。 我这样做是为了在Beamer演示中展示LaTeX文章的外观。

当然,如果要在投影仪中包含一个非常简单的文档(例如,一个简单的文本块),我建议您使用包含某些文本的TikZ“图片”模仿该文档。

也许是另一种方法:与其试图像在文章中那样对Beamer中的内容进行排版,不如将其与文章文档类一起排版,并将结果包含在Beamer文档中。

使用tcolorbox可以自动完成:

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}

\documentclass{beamer}
\usepackage[most]{tcolorbox}

\begin{document}

\begin{frame}[fragile]

\begin{tcblisting}{
    comment only,
  pdf comment,
  compilable listing,
  run pdflatex,
}
\documentclass{article}
\begin{document}
\section{Section Title}
test
\end{document}
\end{tcblisting}

\end{frame}

\end{document}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM