2

I have the file sebmcq.sty created by the excellent users Florent Rougon, Enrico Gregorio to generate a multiple choice questions with answers.

% sebmcq.sty --- Multiple choice questions. Can print questions and proposed
%                answers in a random order. Optionally show the correct
%                answers.
%
% See <https://tex.stackexchange.com/a/529060/73317> for more information.
%
% Copyright (C) 2020  Florent Rougon, Enrico Gregorio
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 can be found in the LICENSE file present in this
% distribution.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Florent Rougon.
%
% This work consists of only one file: sebmcq.sty.
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\RequirePackage{expl3}
\RequirePackage{xparse}
\RequirePackage{l3keys2e}
\RequirePackage{amssymb,bbding}        % for the \checkmark
\ProvidesExplPackage{sebmcq}{2020-03-14}{0.6}
  {Multiple choice questions}

\str_new:N \l_questionnaire_env_str
\seq_new:N \l__sebmcq_questions_seq
\tl_new:N \l__sebmcq_answers_tl
\tl_new:N \l__sebmcq_correctness_code_tl
\tl_new:N \l__sebmcq_answer_tl
\bool_new:N \l_sebmcq_shuffle_questions_bool
\bool_new:N \l_sebmcq_shuffle_answers_bool
\bool_new:N \l_sebmcq_show_correct_answers_bool
\bool_new:N \l__sebmcq_has_correct_answer_bool    % parsing stage
\bool_new:N \l__sebmcq_correct_answer_marked_bool % rendering stage
\skip_new:N \l_sebmcq_after_answer_num_skip        % horizontal skip

\msg_new:nnn { sebmcq } { invalid-answer-opt-arg }
  { Invalid~input~inside~brackets~before~answer:~'#1'. }

\msg_new:nnn { sebmcq } { empty-answer-opt-arg }
  { Empty~input~inside~brackets~before~answer. }

\msg_new:nnn { sebmcq } { question-cmd-used-outside-of-questionnaire-env }
  { \question command~used~outside~of~questionnaire~environment. }

% This is assumed to be illegal
\msg_new:nnn { sebmcq } { several-correct-answers }
  { Several~answers~have~been~marked~as~correct~for~a~question. }

\cs_new_protected:Npn \__sebmcq_read_answer_with_optarg:wn [#1]#2
  {
    \tl_if_empty:nTF {#1}
      { \msg_error:nn { sebmcq } { empty-answer-opt-arg } }
      {
        \str_if_in:nnTF { xX } {#1}
          {
            \bool_if:NTF \l__sebmcq_has_correct_answer_bool
              { \msg_error:nn { sebmcq } { several-correct-answers } }
              {
                \bool_set_true:N \l__sebmcq_has_correct_answer_bool
                \tl_put_right:Nn \l__sebmcq_answers_tl
                  { { { \correct } {#2} } }
              }
          }
          { \msg_error:nnn { sebmcq } { invalid-answer-opt-arg } {#1} }
      }
    \__sebmcq_read_answers:w % recurse
  }

\cs_new_protected:Npn \__sebmcq_read_answer_without_optarg:n #1
  {
    % Incorrect answer
    \tl_put_right:Nn \l__sebmcq_answers_tl { { { } {#1} } }
    \__sebmcq_read_answers:w % recurse
  }

\cs_new_protected:Npn \__sebmcq_read_answers:w
  {
    \peek_meaning_ignore_spaces:NTF \q_stop
      { \use_none:n }
      {
        \peek_meaning_ignore_spaces:NTF [
          { \__sebmcq_read_answer_with_optarg:wn }
          { \__sebmcq_read_answer_without_optarg:n }
      }
  }

\cs_new_protected:Npn \__sebmcq_maybe_mark_correct_answer:
  {
    % Little trick in the boolean expression: this allows us to automatically
    % mark the freeform answer as correct if none of the explicitly given
    % answers was declared as correct.
    \bool_if:nT
      {
          \bool_if_p:N \l_sebmcq_show_correct_answers_bool &&
        ! \bool_if_p:N \l__sebmcq_correct_answer_marked_bool
      }
      {
        \makebox[0pt][r] {\CheckmarkBold \skip_horizontal:n { 0.5em } }
        % No other answer will be marked as correct for this question.
        \bool_set_true:N \l__sebmcq_correct_answer_marked_bool
      }
  }

% Default function for formatting the question number
\cs_new_protected:Npn \sebmcq_format_question_number_default:n #1
  {
    \fbox { \makebox[\height]{ \int_to_Alph:n {#1} } }
  }

% #1: empty means the answer is incorrect
% #2: answer number
% #3: answer text
\cs_new_protected:Npn \__sebmcq_print_proposed_answer:nnn #1#2#3
  {
    \tl_if_empty:nF {#1} { \__sebmcq_maybe_mark_correct_answer: }
    \__sebmcq_format_question_number:n {#2}
    \skip_horizontal:n { \l_sebmcq_after_answer_num_skip } {#3} \\[0.5ex]
  }

\cs_generate_variant:Nn \__sebmcq_print_proposed_answer:nnn { VnV }
\cs_generate_variant:Nn \__sebmcq_format_question_number:n { x }

% Based on egreg's code: <https://tex.stackexchange.com/a/519972/73317>
% #1: question text; #2: proposed answers
\cs_new_protected:Npn \__sebmcq_read_question:nn #1#2
  {
    \tl_clear:N \l__sebmcq_answers_tl
    \bool_set_false:N \l__sebmcq_has_correct_answer_bool
    \__sebmcq_read_answers:w #2 \q_stop
    \seq_put_right:Nx \l__sebmcq_questions_seq
      {
        { \exp_not:n {#1} }                                    % { question }
        { \exp_not:n \exp_after:wN { \l__sebmcq_answers_tl } } % { answers }
      }
  }

\seq_new:N \l__sebmcq_oq_answers_seq

% #1: question
% #2: answers, each of which being of the form
% { { \correct or empty } { answer text } }
\cs_new_protected:Npn \__sebmcq_output_question:nn #1#2
  {
    \seq_set_split:Nnn \l__sebmcq_oq_answers_seq { } {#2}
    \bool_if:NT \l_sebmcq_shuffle_answers_bool
      { \seq_shuffle:N \l__sebmcq_oq_answers_seq }

    \item {#1} \\[2ex]          % question text

    \bool_set_false:N \l__sebmcq_correct_answer_marked_bool
    \seq_indexed_map_inline:Nn \l__sebmcq_oq_answers_seq
      {
        \seq_set_split:Nnn \l_tmpa_seq { } {##2}
        \seq_pop_left:NN \l_tmpa_seq \l__sebmcq_correctness_code_tl
        \seq_pop_left:NN \l_tmpa_seq \l__sebmcq_answer_tl
        \__sebmcq_print_proposed_answer:VnV
          \l__sebmcq_correctness_code_tl {##1}
          \l__sebmcq_answer_tl
      }

    \__sebmcq_maybe_mark_correct_answer:
    \__sebmcq_format_question_number:x
      { \int_eval:n { \seq_count:N \l__sebmcq_oq_answers_seq + 1 } }
    \skip_horizontal:n { \l_sebmcq_after_answer_num_skip }
    \hbox_to_wd:nn { 9em } { \hrulefill }
  }

\cs_new_protected:Npn \__sebmcq_output_question:n #1
  { \__sebmcq_output_question:nn #1 }

\cs_new_protected:Npn \__sebmcq_output_questionnaire:
  {
    \bool_if:NT \l_sebmcq_shuffle_questions_bool
      { \seq_shuffle:N \l__sebmcq_questions_seq }
    % I didn't use \seq_map_inline:Nn here because it would fail with l3kernel
    % older than 2020-03-14 (this is due to a bug in \seq_shuffle:N
    % <https://github.com/latex3/latex3/issues/687>, fixed in this commit:
    % <https://github.com/latex3/latex3/commit/42c70c63fd83324c5792dd14538a39dd7e388a55>).
    \seq_map_function:NN \l__sebmcq_questions_seq \__sebmcq_output_question:n
  }

\NewDocumentCommand \question { }
  {
    \msg_error:nn { sebmcq } { question-cmd-used-outside-of-questionnaire-env }
  }

\NewDocumentEnvironment { questionnaire } { O{} }
  {
    \keys_set:nn { sebmcq } {#1}
    \cs_set_eq:NN \question \__sebmcq_read_question:nn
    \tl_clear:N \l__sebmcq_questions_seq
    \use:c { \str_use:N \l_questionnaire_env_str }
  }
  {
    \__sebmcq_output_questionnaire:
    \use:c { end \str_use:N \l_questionnaire_env_str }
  }

\NewDocumentCommand \ShowCorrectAnswers { }
 {
   \bool_set_true:N \l_sebmcq_show_correct_answers_bool
 }

\NewDocumentCommand \HideCorrectAnswers { }
 {
   \bool_set_false:N \l_sebmcq_show_correct_answers_bool
 }

% Set the default question number formatter
\cs_new_eq:NN \__sebmcq_format_question_number:n
              \sebmcq_format_question_number_default:n

\keys_define:nn { sebmcq }
  {
    after-answer-num-skip .skip_set:N = \l_sebmcq_after_answer_num_skip ,
    after-answer-num-skip .value_required:n = true,
    after-answer-num-skip .initial:n = { 0.9em },
    %
    answer-number-format  .code:n = {
      \cs_set_protected:Npn \__sebmcq_format_question_number:n ##1 {#1} },
    answer-number-format  .value_required:n = true,
    %
    questionnaire-env     .code:n = {
      \str_set:Nn \l_questionnaire_env_str {#1} },
    questionnaire-env     .value_required:n = true,
    questionnaire-env     .initial:n = { enumerate },
    %
    show-correct-answers  .bool_set:N = \l_sebmcq_show_correct_answers_bool,
    show-correct-answers  .initial:n = { false },
    show-correct-answers  .default:n = { true },
    %
    shuffle-questions     .bool_set:N = \l_sebmcq_shuffle_questions_bool,
    shuffle-questions     .initial:n = { false },
    shuffle-questions     .default:n = { true },
    %
    shuffle-answers       .bool_set:N = \l_sebmcq_shuffle_answers_bool,
    shuffle-answers       .initial:n = { false },
    shuffle-answers       .default:n = { true },
  }

\NewDocumentCommand \sebmcqSetup { m }
  {
    \keys_set:nn { sebmcq } {#1}
  }

% Process LaTeX2e-style package options. This uses l3keys2e, see
% <https://tex.stackexchange.com/a/371754/73317> for explanations.
\ProcessKeysPackageOptions { sebmcq }

\endinput

When I create a multiple choice questions (for example) the first column have the question nr. 6 in the first column and the A, B, C, D and E in the second column.

How is it possible to modify the code to produce questions that do not have column breaks between the question and the various choices?

enter image description here

MWE:

\documentclass[leqno,12pt]{extarticle}

\usepackage[italian]{babel}
\usepackage{mathtools,amssymb}
%\usepackage{mathrsfs}
\usepackage{graphicx,multicol,array}
\graphicspath{ {img/} }

\usepackage{geometry}
\geometry{landscape,a3paper,
          tmargin=0.6in,bmargin=0.35in,hmargin=0.35in}
\usepackage[italic,basic, default mathsizes]{mathastext}
\MTlettershape{sl}\Mathastext

\makeatletter
\@for\@tempa:=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z\do{%
\MTsetmathskips{\@tempa}{0mu}{0.5mu}}%
\@for\@tempa:=A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z\do{%
\MTsetmathskips{\@tempa}{0mu}{0.5mu}}%
\makeatother
\usepackage{expl3}             % for \int_to_alph:n
\usepackage{xparse}                       % only for the 'test' environment
\usepackage[shuffle-questions, shuffle-answers]{sebmcq}
\pagestyle{empty}
\ExplSyntaxOn
\NewDocumentEnvironment { test } { m +b }
  { \prg_replicate:nn { #1 } { #2 \clearpage } }
  { }
\ExplSyntaxOff
\ShowCorrectAnswers
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\headheight}{16pt}
\lhead{\sffamily\bfseries \textsc{ }}
\chead{\sffamily\bfseries a.s. 2021--2022}
\rhead{\sffamily\bfseries Test }
\usepackage{enumitem}
\usepackage{icomma}
\usepackage{tikz}
\begin{document}
\large
\begin{multicols}{2}
\begin{questionnaire}

\question{In notazione scientifica, il numero 0.00364
diventa}
{
    {$3.64 \times 10^3$.}
    {$3.64 \times 10^2$.}
    {$3.64 \times 10^{-2}$.}
     [X]{$3.64 \times 10^{-3}$.}
}

\question{Un volume di 10 cm$^3$ è uguale a:}
{
    {0.1 dm$^3$.}
    {100 mm$^3$.}
   [X]{10000 mm$^3$.}
    {0.00001 mm$^3$.}
}

\question{Quale unità SI è più appropriata per
misurare lo spessore di un foglio di carta?}
{
    {il metro.}
    [X]{il millimetro.}
   {il decimetro.}
    {il chilometro.}
}

\question{Sono grandezze fondamentali nel Sistema
Internazionale \ldots}
{
    {volume, densità e peso specifico.}
    {massa e densità.}
   [X]{temperatura e massa.}
    {volume e tempo.}
}


\question{Una grandezza fisica derivata \ldots }
{
    {ha un'unità di misura definita dal rapporto tra le unità di misura di grandezze fondamentali.}
    {non ha unità di misura.}
   [X]{è definita attraverso una relazione con le grandezze fondamentali.}
    {ha un'unità di misura definita dal prodotto delle unità di misura di grandezze fondamentali.}
}


\question{Quante sono le cifre significative nel
numero $2.50 \times 10^4$?}
{
    {due.}
    {quattro.}
   [X]{tre.}
    {sette.}
}


\question{Quale grandezza si può misurare con una bilancia a bracci uguali?}
{
    {La quantità di sostanza.}
    {Il peso.}
   [X]{La massa.}
    {La forza.}
}


\question{L'unità di misura della velocità nel S.I. è:}
{
    {km/h.}
    {km/s.}
   [X]{m/s.}
    {cm/s.}
}


\question{Quanti zeri sono significativi nel numero 40 400 302?}
{
    {uno.}
    {due.}
   [X]{quattro.}
    {tre.}
}


\question{La massa di un corpo \ldots}
{
    {varia al variare della temperatura del corpo.}
    {varia al variare della posizione del corpo.}
   [X]{è un valore costante del corpo.}
    {varia al variare della distanza del corpo dalla
Terra.}
}




\end{questionnaire}
\end{multicols}
\end{document}

1 Answer 1

1

The simplest way is to disallow a page/column break after the question text, which is achieved by replacing

    \item {#1} \\[2ex]          % question text

with

    \item {#1} \\*[2ex]          % question text

I had to modify slightly the geometry to bmargin=0.4in in order to reproduce the issue.

Other changes:

    questionnaire-env     .code:n = {
      \str_set:Nn \l_questionnaire_env_str {#1} },

should be

    questionnaire-env     .str_set:N = \l_questionnaire_env_str,

and

    \seq_put_right:Nx \l__sebmcq_questions_seq
      {
        { \exp_not:n {#1} }                                    % { question }
        { \exp_not:n \exp_after:wN { \l__sebmcq_answers_tl } } % { answers }
      }

should be

    \seq_put_right:Nx \l__sebmcq_questions_seq
      {
        { \exp_not:n {#1} }                  % { question }
        { \exp_not:V \l__sebmcq_answers_tl } % { answers }
      }

By the way, I have no bearing with that style file. Maybe I suggested something, but definitely didn't write all that code.

Here's an edited version of the .sty file

% sebmcq.sty --- Multiple choice questions. Can print questions and proposed
%                answers in a random order. Optionally show the correct
%                answers.
%
% See <https://tex.stackexchange.com/a/529060/73317> for more information.
%
% Copyright (C) 2020  Florent Rougon, Enrico Gregorio
%%%
%%% Modified by egreg
%%%
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 can be found in the LICENSE file present in this
% distribution.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Florent Rougon.
%
% This work consists of only one file: sebmcq.sty.
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\RequirePackage{expl3}
\RequirePackage{xparse}
\RequirePackage{l3keys2e}
\RequirePackage{amssymb,bbding}        % for the \checkmark
\ProvidesExplPackage{sebmcq}{2020-03-14}{0.6}
  {Multiple choice questions}

\str_new:N \l_questionnaire_env_str
\seq_new:N \l__sebmcq_questions_seq
\tl_new:N \l__sebmcq_answers_tl
\tl_new:N \l__sebmcq_correctness_code_tl
\tl_new:N \l__sebmcq_answer_tl
\bool_new:N \l_sebmcq_shuffle_questions_bool
\bool_new:N \l_sebmcq_shuffle_answers_bool
\bool_new:N \l_sebmcq_show_correct_answers_bool
\bool_new:N \l__sebmcq_has_correct_answer_bool    % parsing stage
\bool_new:N \l__sebmcq_correct_answer_marked_bool % rendering stage
\skip_new:N \l_sebmcq_after_answer_num_skip        % horizontal skip

\msg_new:nnn { sebmcq } { invalid-answer-opt-arg }
  { Invalid~input~inside~brackets~before~answer:~'#1'. }

\msg_new:nnn { sebmcq } { empty-answer-opt-arg }
  { Empty~input~inside~brackets~before~answer. }

\msg_new:nnn { sebmcq } { question-cmd-used-outside-of-questionnaire-env }
  { \question command~used~outside~of~questionnaire~environment. }

% This is assumed to be illegal
\msg_new:nnn { sebmcq } { several-correct-answers }
  { Several~answers~have~been~marked~as~correct~for~a~question. }

\cs_new_protected:Npn \__sebmcq_read_answer_with_optarg:wn [#1]#2
  {
    \tl_if_empty:nTF {#1}
      { \msg_error:nn { sebmcq } { empty-answer-opt-arg } }
      {
        \str_if_in:nnTF { xX } {#1}
          {
            \bool_if:NTF \l__sebmcq_has_correct_answer_bool
              { \msg_error:nn { sebmcq } { several-correct-answers } }
              {
                \bool_set_true:N \l__sebmcq_has_correct_answer_bool
                \tl_put_right:Nn \l__sebmcq_answers_tl
                  { { { \correct } {#2} } }
              }
          }
          { \msg_error:nnn { sebmcq } { invalid-answer-opt-arg } {#1} }
      }
    \__sebmcq_read_answers:w % recurse
  }

\cs_new_protected:Npn \__sebmcq_read_answer_without_optarg:n #1
  {
    % Incorrect answer
    \tl_put_right:Nn \l__sebmcq_answers_tl { { { } {#1} } }
    \__sebmcq_read_answers:w % recurse
  }

\cs_new_protected:Npn \__sebmcq_read_answers:w
  {
    \peek_meaning_ignore_spaces:NTF \q_stop
      { \use_none:n }
      {
        \peek_meaning_ignore_spaces:NTF [
          { \__sebmcq_read_answer_with_optarg:wn }
          { \__sebmcq_read_answer_without_optarg:n }
      }
  }

\cs_new_protected:Npn \__sebmcq_maybe_mark_correct_answer:
  {
    % Little trick in the boolean expression: this allows us to automatically
    % mark the freeform answer as correct if none of the explicitly given
    % answers was declared as correct.
    \bool_if:nT
      {
          \bool_if_p:N \l_sebmcq_show_correct_answers_bool &&
        ! \bool_if_p:N \l__sebmcq_correct_answer_marked_bool
      }
      {
        \makebox[0pt][r] {\CheckmarkBold \skip_horizontal:n { 0.5em } }
        % No other answer will be marked as correct for this question.
        \bool_set_true:N \l__sebmcq_correct_answer_marked_bool
      }
  }

% Default function for formatting the question number
\cs_new_protected:Npn \sebmcq_format_question_number_default:n #1
  {
    \fbox { \makebox[\height]{ \int_to_Alph:n {#1} } }
  }

% #1: empty means the answer is incorrect
% #2: answer number
% #3: answer text
\cs_new_protected:Npn \__sebmcq_print_proposed_answer:nnn #1#2#3
  {
    \tl_if_empty:nF {#1} { \__sebmcq_maybe_mark_correct_answer: }
    \__sebmcq_format_question_number:n {#2}
    \skip_horizontal:n { \l_sebmcq_after_answer_num_skip } {#3} \\[0.5ex]
  }

\cs_generate_variant:Nn \__sebmcq_print_proposed_answer:nnn { VnV }
\cs_generate_variant:Nn \__sebmcq_format_question_number:n { x }

% Based on egreg's code: <https://tex.stackexchange.com/a/519972/73317>
% #1: question text; #2: proposed answers
\cs_new_protected:Npn \__sebmcq_read_question:nn #1#2
  {
    \tl_clear:N \l__sebmcq_answers_tl
    \bool_set_false:N \l__sebmcq_has_correct_answer_bool
    \__sebmcq_read_answers:w #2 \q_stop
    \seq_put_right:Nx \l__sebmcq_questions_seq
      {
        { \exp_not:n {#1} }                  % { question }
        { \exp_not:V \l__sebmcq_answers_tl } % { answers }
      }
  }

\seq_new:N \l__sebmcq_oq_answers_seq

% #1: question
% #2: answers, each of which being of the form
% { { \correct or empty } { answer text } }
\cs_new_protected:Npn \__sebmcq_output_question:nn #1#2
  {
    \seq_set_split:Nnn \l__sebmcq_oq_answers_seq { } {#2}
    \bool_if:NT \l_sebmcq_shuffle_answers_bool
      { \seq_shuffle:N \l__sebmcq_oq_answers_seq }

    \item {#1} \\*[2ex]          % question text

    \bool_set_false:N \l__sebmcq_correct_answer_marked_bool
    \seq_indexed_map_inline:Nn \l__sebmcq_oq_answers_seq
      {
        \seq_set_split:Nnn \l_tmpa_seq { } {##2}
        \seq_pop_left:NN \l_tmpa_seq \l__sebmcq_correctness_code_tl
        \seq_pop_left:NN \l_tmpa_seq \l__sebmcq_answer_tl
        \__sebmcq_print_proposed_answer:VnV
          \l__sebmcq_correctness_code_tl {##1}
          \l__sebmcq_answer_tl
      }

    \__sebmcq_maybe_mark_correct_answer:
    \__sebmcq_format_question_number:x
      { \int_eval:n { \seq_count:N \l__sebmcq_oq_answers_seq + 1 } }
    \skip_horizontal:n { \l_sebmcq_after_answer_num_skip }
    \hbox_to_wd:nn { 9em } { \hrulefill }
  }

\cs_new_protected:Npn \__sebmcq_output_question:n #1
  { \__sebmcq_output_question:nn #1 }

\cs_new_protected:Npn \__sebmcq_output_questionnaire:
  {
    \bool_if:NT \l_sebmcq_shuffle_questions_bool
      { \seq_shuffle:N \l__sebmcq_questions_seq }
    % I didn't use \seq_map_inline:Nn here because it would fail with l3kernel
    % older than 2020-03-14 (this is due to a bug in \seq_shuffle:N
    % <https://github.com/latex3/latex3/issues/687>, fixed in this commit:
    % <https://github.com/latex3/latex3/commit/42c70c63fd83324c5792dd14538a39dd7e388a55>).
    \seq_map_function:NN \l__sebmcq_questions_seq \__sebmcq_output_question:n
  }

\NewDocumentCommand \question { }
  {
    \msg_error:nn { sebmcq } { question-cmd-used-outside-of-questionnaire-env }
  }

\NewDocumentEnvironment { questionnaire } { O{} }
  {
    \keys_set:nn { sebmcq } {#1}
    \cs_set_eq:NN \question \__sebmcq_read_question:nn
    \tl_clear:N \l__sebmcq_questions_seq
    \use:c { \str_use:N \l_questionnaire_env_str }
  }
  {
    \__sebmcq_output_questionnaire:
    \use:c { end \str_use:N \l_questionnaire_env_str }
  }

\NewDocumentCommand \ShowCorrectAnswers { }
 {
   \bool_set_true:N \l_sebmcq_show_correct_answers_bool
 }

\NewDocumentCommand \HideCorrectAnswers { }
 {
   \bool_set_false:N \l_sebmcq_show_correct_answers_bool
 }

% Set the default question number formatter
\cs_new_eq:NN \__sebmcq_format_question_number:n
              \sebmcq_format_question_number_default:n

\keys_define:nn { sebmcq }
  {
    after-answer-num-skip .skip_set:N = \l_sebmcq_after_answer_num_skip ,
    after-answer-num-skip .value_required:n = true,
    after-answer-num-skip .initial:n = { 0.9em },
    %
    answer-number-format  .code:n = {
      \cs_set_protected:Npn \__sebmcq_format_question_number:n ##1 {#1} },
    answer-number-format  .value_required:n = true,
    %
    questionnaire-env     .str_set:N = \l_questionnaire_env_str,
    questionnaire-env     .value_required:n = true,
    questionnaire-env     .initial:n = { enumerate },
    %
    show-correct-answers  .bool_set:N = \l_sebmcq_show_correct_answers_bool,
    show-correct-answers  .initial:n = { false },
    show-correct-answers  .default:n = { true },
    %
    shuffle-questions     .bool_set:N = \l_sebmcq_shuffle_questions_bool,
    shuffle-questions     .initial:n = { false },
    shuffle-questions     .default:n = { true },
    %
    shuffle-answers       .bool_set:N = \l_sebmcq_shuffle_answers_bool,
    shuffle-answers       .initial:n = { false },
    shuffle-answers       .default:n = { true },
  }

\NewDocumentCommand \sebmcqSetup { m }
  {
    \keys_set:nn { sebmcq } {#1}
  }

% Process LaTeX2e-style package options. This uses l3keys2e, see
% <https://tex.stackexchange.com/a/371754/73317> for explanations.
\ProcessKeysPackageOptions { sebmcq }

\endinput
4
  • Kindest Prof. :-) no no...it was the very kind @frougon that have written all if I remember well. Hence....what is the complete and definitive sebmcq.sty with all the changes? :-)))))) I got out of the hospital yesterday but my head is whirring like in a blender. I went back to school this morning despite the doctors advice to the contrary.
    – Sebastiano
    Commented Nov 26, 2021 at 21:56
  • I have done all your suggestion but I have ! File ended while scanning definition of __sebmcq_read_question:nn. <inserted text> } l.34 ? like as mistake. :-(
    – Sebastiano
    Commented Nov 26, 2021 at 22:10
  • 1
    @Sebastiano I added a full version of the edited .sty.
    – egreg
    Commented Nov 26, 2021 at 22:25
  • Grazieeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
    – Sebastiano
    Commented Nov 26, 2021 at 22:27

You must log in to answer this question.

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