没有样式文件时,以下 MWE 仍按预期工作。
\documentclass[a4paper, 11pt, oneside, onecolumn]{memoir}
\usepackage{StyleFile}
\begin{document}
\include{Chap1}
\include{Chap2}
\end{document}
其中 Chap1 和 Chap2 文件为:
\chapter{Chapter 1}
\section{Section 1}
"Hello from first section "
\section{Section 2}
"Hello from second section "
和
\chapter{Chapter 2}
\section{Section 1}
"Hello from first section "
\section{Section 2}
"Hello from second section "
\section{Section 3}
"Hello from third section "
但有些样式文件的内容会导致系统在进入第 1 章之前挂起。例如
\setSingleSpace{\baselinestretch}
\sidebar{\resizebox{!}{}{\thechapter}}
其中每行单独至少可以进入 Chap1,但两行合在一起则不能,
那么,在样式文件中应该避免哪些类型的内容以便处理包含内容?
PS 看起来我把这个删减太多了。原始样式文件包含在内
\makechapterstyle{mypedersen}{%
\chapterstyle{default}
\setlength{\beforechapskip}{-20pt}
\setlength{\afterchapskip}{10pt}
\setlength{\cftchapternumwidth}{50mm}
\setlength{\wraptwidth}{3cm}
\setsecheadstyle{\Large\bfseries\color{HeadingsRed}}% Set \section style.
\setsubsecheadstyle{\large\bfseries}% Set \subsection style
\renewcommand*{\chapnamefont}{\normalfont\LARGE\itshape}
\renewcommand*{\chapnumfont}{\oldstylenums\HUGE\itshape\colorchapnum}
\renewcommand*{\chaptitlefont}{\normalfont\huge\itshape\colorchaptitle}
\renewcommand*{\afterchapternum}{}
\renewcommand*{\printchaptername}{}
\setlength{\midchapskip}{20mm}%Was \numberheight
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{%
\sidebar{%
\hspace*{-48pt}% <-- added
\raisebox{0pt}[0pt][0pt]{\makebox[0pt][l]{%
\resizebox{!}{\midchapskip}{\chapnumfont\thechapter}}}}}%
\renewcommand*{\printchaptertitle}[1]{\chaptitlefont ##1}}
在我把代码拆分成单独的章节之前,它一直运行良好。当然,这需要先定义一些颜色和宽度。
答案1
\documentclass[a4paper, 11pt, oneside, onecolumn]{memoir}
\begin{document}
\resizebox{!}{}{\thechapter}
\end{document}
产生错误
! Undefined control sequence.
l.6 \resizebox
{!}{}{\thechapter}
?
由于graphicx
尚未加载
\documentclass[a4paper, 11pt, oneside, onecolumn]{memoir}
\usepackage{graphicx}
\begin{document}
\resizebox{!}{}{\thechapter}
\end{document}
产生错误
Runaway definition?
->}\ifx \@tempb \@tempa \ifx \@tempc \@tempa \toks@ {\mbox }\else \toks@ \ETC.
! File ended while scanning definition of \@tempc.
<inserted text>
}
<*> aa125
?
因为尚未指定文本的强制缩放尺寸。
由于错误导致它占用了整个文件,因此您将在提示符*
处结束(在默认交互模式下),tex 将等待您输入更多输入
?
*
(Please type a command or say `\end')
*\stop
[1{/usr/local/texlive/2023/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]</usr/
local/texlive/2023/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on aa125.pdf (1 page, 9001 bytes).
Transcript written on aa125.log.
因此,该错误与使用包无关,或者\include
仅仅是 tex 输入中的错误。