1

I'd like to define a theorem environment called sol in order to write solutions to exercises. I've done so through

\documentclass[a4paper]{article}
\usepackage{amsthm}
\newtheorem{ex}{Exercise}[subsection]
\newtheorem*{sol}{Solution}

\begin{document}

\renewcommand{\theenumi}{\alph{enumi}}
\renewcommand{\labelenumi}{\theenumi}

\begin{ex} Question
\end{ex}

\begin{sol} Solution
\end{sol}

\begin{ex} Question
   \begin{enumerate}
      \item First part
      \item Second part
   \end{enumerate}
\end{ex}

\begin{sol}
   \begin{enumerate}
      \item First part
      \item Second part
   \end{enumerate}
\end{sol}

\end{document}

This works fine with simple questions, but it looks a bit awkward with multipart questions (as illustrated by the previous mwe). I think it would look better if part a started in a newline rather than following the Solution tag. I've tried adding \\ right after \begin{sol} or before or after \begin{enumerate}. But I get errors ("There's no line here to end").

Is there a way of adding the newline after the Solution tag and the list number?

1
  • 1
    Add \mbox{} instead.
    – egreg
    Sep 30, 2021 at 15:46

2 Answers 2

2

In this particular case, in which you defined solution as a newtheorem you can proceed as in section 2.1 of amsthm manual. One way is with \leavemode command, but it has some problems explained in the manual.

\documentclass[a4paper]{article}
\usepackage{amsthm}
\newtheorem{ex}{Exercise}[subsection]
\newtheorem*{sol}{Solution}

\begin{document}

\renewcommand{\theenumi}{\alph{enumi}}
\renewcommand{\labelenumi}{\theenumi}

\begin{sol}
\leavevmode
   \begin{enumerate}
      \item First part
      \item Second part
   \end{enumerate}
\end{sol}

\end{document}

enter image description here

An alternative method is to define a theorem style to perform this breaks (also from the manual):

\newtheoremstyle{break}%
  {}{}%
  {\itshape}{}%
  {\bfseries}{}%  % Note that final punctuation is omitted.
  {\newline}{}
0

You can trick the enumerate by adding an empty item.

\begin{sol}
   \begin{enumerate}
      \item[]
      \item First part
      \item Second part
   \end{enumerate}
\end{sol}

enter image description here

1
  • 1
    Welcome to TeX.SE!
    – Mensch
    Sep 30, 2021 at 15:34

You must log in to answer this question.

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