0

Problem:

This issue is related to the following post: Align enumerate to text and items to numbering for exercises and answers - but it deals with a different aspect of the package tasks, namely how to get tasks to adapt in width.

Minimal Working Example (MWE):

\documentclass{article}
\usepackage{amsmath}
\usepackage[shortlabels,inline]{enumitem}
\usepackage[lastexercise,answerdelayed,exercisedelayed]{exercise}
\usepackage{showframe}
\usepackage{tasks}
% --------------------------------------------------------------
% Exercise and answer options
% --------------------------------------------------------------
\renewcommand{\ExerciseName}{}
\renewcommand{\AnswerName}{}
\renewcommand{\ExerciseHeader}{\noindent{\textbf{\ExerciseHeaderNB}} \ExerciseTitle}
\renewcommand{\AnswerHeader}{\noindent{\textbf{\ExerciseHeaderNB}} \ExerciseTitle}
\setlength{\ExerciseSkipBefore}{0pt}
\usepackage{xpatch} 
\renewcommand{\QuestionNB}{\textbf{\alph{Question})\ }}
\setlength{\QuestionBefore}{0.67em}

\begin{document}

% --------------------------------------------------------------
% Exercise 1
% --------------------------------------------------------------
\begin{Exercise}
 Some text here
 \Question Question 1 here
\end{Exercise}

% --------------------------------------------------------------
% Answer 1
% --------------------------------------------------------------
\begin{Answer}
    \vspace*{-\dimexpr\baselineskip + \topsep}
    \begin{tasks}[label-format=\bfseries](4)
        \task $x<-2$
        \task $x>2$
        \task $(x \leq 1) \vee (x>2)$
        \task $0<x<3$
    \end{tasks}
\end{Answer}

% --------------------------------------------------------------
% Prints out exercises and answers
% --------------------------------------------------------------
\section{Exercises}
\shipoutExercise
\section{Answers}
\shipoutAnswer

\end{document}

Current output:

enter image description here

Desired output:

Adapt width of all options so that option c) may fit in one row.

  • The simplest would be to have smaller margins, if you don't want to use marginal note. Just loading geometry does that by default. Other than that, set the number of columns to $3$. – Bernard Jul 16 at 8:49
  • I can't use geometry because it will create a ripple of undesired changes in the document. Setting the column number to $3$ generates a lot of errors. Is there any other way to solve the width of each task? – kexxcream Jul 16 at 10:27
  • Changing the number of columns shouldn't generate an error by itself. Could you show the relevant lines in the .log file? Another possibility is to force answer c) spreading over the last two columns, using \task*. In this case, d) will go to a second row, under a). – Bernard Jul 16 at 10:37
  • For some reason, column c) does not seem to get wide enough. Is there an option to decide how wide each column can be? – kexxcream Jul 16 at 15:03
1

The columns of tasks cannot adapt to the items. The available width always is split evenly.

Either use less columns, e.g., \begin{tasks}(2) or \begin{tasks}(3), or let the third item span two columns:

\begin{tasks}(4)
  \task $x<-2$
  \task $x>2$
  \task*(2) $(x \leq 1) \vee (x>2)$
  \task $0<x<3$
\end{tasks}

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.