我正在用回憶錄課編寫問題單的解決方案。我想保留原始表格中的問題標籤。
問題表1
問題1.13.1洛雷姆·伊普蘇姆 ...
問題1.13.2洛雷姆·伊普蘇姆 ...
這是我的做法(不整潔的 MWE):
\documentclass[extrafontsizes,oneside,20pt]{memoir}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{memhfixc}
% ugly workaround (1)
\newcommand{\sectionitem}{%
\item\phantomsection\addcontentsline{toc}{section}{%
\let\sectionitemfont\relax%
\labelenumi%
\let\sectionitemfont\bfseries%
}%
}
\def\mychapter{Problem sheet}
\makechapterstyle{mine}{%
\renewcommand{\printchaptername}{\chapnumfont \mychapter}
\renewcommand{\printchaptertitle}[1]{}
}
\renewcommand*{\cftchaptername}{\mychapter\space}
\begin{document}
\clearpage
\chapterstyle{default} % (2)
\tableofcontents
\clearpage
\chapterstyle{mine} % (2)
\let\sectionitemfont\bfseries
\chapter{A}
\begin{enumerate}[
leftmargin=*,
label=\sectionitemfont problem 1.13.\arabic*
]
\sectionitem Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\\
\textbf{solution}
\sectionitem Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\\
\textbf{solution}
\sectionitem Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\\
\textbf{solution}
\end{enumerate}
\end{document}
醜陋的解決方法(1)
用於\labelenumi
強制枚舉項出現在目錄中。結果是我想要的,但有 hyperref 警告:
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\<let>-command' on input line 39.
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\sectionitemfont' on input line 39.
我也不喜歡的是章節樣式切換(2)
。我希望章節(問題表)名稱只出現在目錄中,但我也想保留較大的名稱內容標題。回憶錄有一個命令\renewcommand{\printchaptertitle}[1]
可以關閉章節標題(但是內容也是章節標題)。
有沒有更乾淨的方法可以達到相同的結果?
PS 在回憶錄手冊第 88 頁上的預設值中\newcommand{\printchaptertitle}[1]{\chaptitlefont #1}
,在上述 MWE 中給出了錯誤(帶有renewcommand
),但##1
沒有(並且有效)。
答案1
這可能是個解決方案:
\documentclass[extrafontsizes,oneside,20pt]{memoir}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{memhfixc}
\newenvironment{probsol}[1][\thesection]{\begin{enumerate}[leftmargin=*,
label=\sectionitemfont#1.\arabic{enumi}]\let\olditem\item\def\item{\olditem\addcontentsline{toc}{section}{#1.\arabic{enumi}}}}
{\end{enumerate}}
\def\mychapter{Problem sheet}
\makechapterstyle{mine}{%
\renewcommand{\printchaptername}{\chapnumfont \mychapter}
\renewcommand{\printchaptertitle}[1]{}
}
\begin{document}
\clearpage
\chapterstyle{default} % (2)
\tableofcontents
\clearpage
\chapterstyle{mine} % (2)
\let\sectionitemfont\bfseries
\chapter{A}
\begin{probsol}[problem 1.13]
\item Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\\
\textbf{solution}
\item Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\\
\textbf{solution}
\item Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\\
\textbf{solution}
\end{probsol}
\end{document}