
私は回想録の授業で問題シートの解答を書いています。元のシートの問題のラベルを保存しておきたいです。
問題シート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
、列挙項目を強制的に ToC に表示します。結果は望みどおりですが、ハイパー参照の警告が表示されます。
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)
。章(問題シート)の名前は目次にのみ表示したいのですが、大きなコンテンツタイトル。Memoirには\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}