2

I am typing a set of exercises with an 'answers' package. MWE:

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[OT1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{answers}

\Newassociation{sol}{Solution}{ans}
\renewcommand{\Solutionlabel}[1]{\textbf{#1.}}
\theoremstyle{plain}
\newtheorem{ex}{}


\begin{document}
\Opensolutionfile{ans}[ans1]
\section{Problems}
\begin{ex}
$2+2=?$
\begin{sol}
$4$.
\end{sol}
\end{ex}
\begin{ex}
$1+2=?$
\begin{sol}
$3$.
\end{sol}
\end{ex}
\Closesolutionfile{ans}
\section{Answers}
\input{ans1}
\end{document} 

enter image description here

Everything is fine. But I want these short answers go in one paragraph like this: enter image description here How to achieve it? This should be simple, but the manual is very concise and is missing a lot of details.

Restriction: I cannot use exam package as I need to use these exercises in tufte-style book eventually, so I cannot do \documentclass{exam}.

Acceptable answer: The answer could be the suggestion of the package that allows doing the same stuff with a continuous enumeration of the problems through the entire book and the answers printed at the end of the document but by \section and with the continuous enumeration.

  • I have a question, does the TEX language solve equations? – LCarvalho Feb 2 '18 at 8:37
  • 1
    TeX is for typesetting, you solve equations yourself. – Sergey Belyaev Feb 2 '18 at 12:56
2

Just add one line:

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[OT1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{answers}

\Newassociation{sol}{Solution}{ans}
\renewcommand{\Solutionlabel}[1]{\textbf{#1.}}
\renewenvironment{Solution}[1]{\textbf{#1.} }{\quad}  % This line added
\theoremstyle{plain}
\newtheorem{ex}{}

\begin{document}
\Opensolutionfile{ans}[ans1]
\section{Problems}
\begin{ex}
$2+2=?$
\begin{sol}
$4$.
\end{sol}
\end{ex}
\begin{ex}
$1+2=?$
\begin{sol}
$3$.
\end{sol}
\end{ex}
\Closesolutionfile{ans}
\section{Answers}
\input{ans1}
\end{document} 
  • I knew it is simple. Thank you. The manual is not very detailed (or I am not smart enough :) ) – Sergey Belyaev Feb 2 '18 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.