
LaTeXワークフローに関するスレッドを読んでいたとき、https://tex.stackexchange.com/a/22433/32782これは、本の章にスタンドアロン パッケージを使用できる人が複数いることを示しています。通常、人々は\includeonly
スタンドアロン パッケージではなく、文書を複数の tex ファイルに分割し、1 つの tex ファイルだけをアクティブ化するために使用しますが、スタンドアロンを使用するというアイデアは興味をそそられ、セクションのある記事から始めて試してみる必要があると思いましたが、私の例はうまくいかないようです。これが私の例です。
メインのTexファイルflying-animals.tex
:
\documentclass{article}
\usepackage{standalone}
\begin{document}
\input{dragons}
\input{birds}
\input{superman}
\end{document}
そして、1つのセクションの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
1 つの長いページが作成されるため、これは理想的とは言えません。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}