1

I'm writing solutions to problem sheets with memoir class. I want to keep problems' labels from original sheets.

Problem sheet 1

problem 1.13.1 Lorem ipsum ...

problem 1.13.2 Lorem ipsum ...

Here is my way of doing so (untidy 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}

Ugly workaround (1) uses \labelenumi to force enumerate item to appear in ToC. The result is what I want, but there are hyperref warnings:

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.

What I also don't like about this is chapterstyle switching (2). I want chapter (problem sheets) names to appear only in ToC, but I also want to keep large Contents title. Memoir has command \renewcommand{\printchaptertitle}[1] which allows turning off chapter titles (but Contents is also chapter title).

Are there cleaner ways for achieving same result?

P.S. In memoir manual the default \newcommand{\printchaptertitle}[1]{\chaptitlefont #1} on page 88, gives error in above MWE (with renewcommand), but ##1 does not (and works).

1 Answer 1

1

This could be a solution:

\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}

enter image description here

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .