
當我閱讀有關 LaTeX 工作流程的帖子時,我在https://tex.stackexchange.com/a/22433/32782這似乎表明有不止一個人可以使用書籍章節的獨立包。通常人們會使用\includeonly
獨立包而不是獨立包來將文檔分成不同的tex 文件並僅激活一個tex 文件,但是使用獨立包的想法引起了我的興趣,我認為我應該嘗試一下,從一篇首先包含章節的文章開始,但我的例子似乎不起作用。這是我的例子:
主 tex 檔flying-animals.tex
:
\documentclass{article}
\usepackage{standalone}
\begin{document}
\input{dragons}
\input{birds}
\input{superman}
\end{document}
以及一個 tex 檔的一個部分dragons.tex
:
\documentclass{standalone}
\begin{document}
\section{Theories of dragons}
Being dragons.
\subsection{Theory of angry dragons}
Being angry dragons.
\subsection{Theory of tiny dragons}
Being tiny dragons.
\end{document}
當我編譯時dragons.tex
,出現以下錯誤。
LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.3 \section
{Theories of dragons}
是否可以對部分進行獨立工作?
答案1
作為一個選項添加varwidth
到類別中dragons.tex
,效果很好。請注意,如果編譯,dragons.tex
您將獲得一個長頁面,因此這遠非理想。standalone
主要用於由 TikZ 或 PSTricks 創建的圖形。
\documentclass[12pt]{article}
\usepackage{standalone}
\usepackage{lipsum}
\usepackage{filecontents}
% writes the following to dragons.tex
\begin{filecontents*}{dragons.tex}
\documentclass[varwidth]{standalone}
\usepackage{lipsum}
\begin{document}
\section{Theories of dragons}
Being dragons.
\lipsum
\subsection{Theory of angry dragons}
Being angry dragons.
\lipsum
\subsection{Theory of tiny dragons}
Being tiny dragons.
\lipsum
\end{document}
\end{filecontents*}
\begin{document}
\input{dragons}
\end{document}