4

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.

1 Answers1

5

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}