El entorno de doble espacio se comporta de manera extraña y no tengo idea de cómo hacerlo.

El entorno de doble espacio se comporta de manera extraña y no tengo idea de cómo hacerlo.

Soy un profesor de secundaria que busca replicar el formato de un examen común usando TeX. Para intentar hacerlo más fácil para mí, estoy tratando de escribir comandos que me permitan imitar preguntas comunes. Actualmente tengo algunos problemas con el entorno de doble espacio: el formato utiliza doble espacio para crear líneas de preguntas. Aquí hay un ejemplo práctico de mí implementando esto:

\newcounter{qnumber}
\newcounter{partnumber}[qnumber]
\newcommand{\writeq}[3][0]{ %simple written question command
    \stepcounter{qnumber}
    \textbf{Question \arabic{qnumber}\hfill (#2 marks)}\\
    #3\\
    \begin{doublespace}
        \foreach \n in {1,...,#1}{\rule{\linewidth}{0.5pt}\\}
    \end{doublespace}    
}

\writeq[3]{4}{My question is this one.}

ingrese la descripción de la imagen aquí

Entonces, ahora quiero crear "preguntas de varias partes" y he construido el siguiente comando:

%Multi-part question commands
\newcommand{\mpqstem}[2]{
    \stepcounter{qnumber}
    \setcounter{partnumber}{0}  % Reset part number
    \noindent \textbf{Question \arabic{qnumber}\hfill (#1 marks)}\\ \\ 
    #2 \vspace{0.2cm}
}

\newcommand{\mpq}[3][0]{ %simple written question command
    \stepcounter{partnumber}
    \alph{partnumber}) \hangindent=1.27cm \hangafter=0 #3\\
    \rule{0pt}{1pt}\hfill(#2 marks)\vspace{0.5cm}
    \begin{doublespace}
        \foreach \n in {1,...,#1}{\rule{\linewidth-1.27cm}{0.5pt}\\}
    \end{doublespace} 
}

La raíz se usa para establecer el contexto, y el comando mpq es la pregunta real relacionada con esa parte. Sin embargo, al usar esta combinación, obtengo que el texto esté a doble espacio pero no las líneas, y no puedo entender por qué. Vea a continuación cómo intento usar el comando y lo que obtengo:

\mpqstem{4}{This is the scary question, and thankfully this bit is showing up okay without any double-spacing. But that also makes sense, since this command doesn't touch the spacing.}

\mpq[2]{2}{This is part 1, and it's going to be very long to show what is happening with the spacing and make it clear that this is double-spaced.}

\mpq[2]{2}{This is part 2, and it's also going to be very long to show what is happening with the spacing and make it clear that this is double-spaced.}

ingrese la descripción de la imagen aquí

Respuesta1

Su fragmento de código no es compilable porque carece de mucha información crucial. Sin embargo, por supuesto, toma en serio la sugerencia de @UlrikeFischer y deja de usar \\en lugar de \par. Por ejemplo, para los tres comandos, el siguiente código puede resultar útil para lograr sus objetivos finales de formato.

\newcounter{qnumber}
\newcounter{partnumber}[qnumber] tie 'partnumber' counter to 'qnumber' counter

\newcommand{\writeq}[3][0]{ %simple written question command
    \refstepcounter{qnumber} % use \refstepcounter, not \stepcounter
    \par\noindent
    \textbf{Question \arabic{qnumber}\hfill(#2 marks)}
    \par
    #3
    \par
    \begin{doublespace}
        \foreach \n in {1,\dots,#1}{\rule{\linewidth}{0.5pt}}
        \par
    \end{doublespace}
}

\newcommand{\mpqstem}[2]{
    \refstepcounter{qnumber}
    %%\setcounter{partnumber}{0}  % not needed
    \par\noindent 
    \textbf{Question \arabic{qnumber}\hfill(#1 marks)}
    \par
    \vspace{1\baselineskip}
    #2 
    \par
    \vspace{2mm}
}

\newcommand{\mpq}[3][0]{ %simple written question command
    \refstepcounter{partnumber}
    \par\noindent \hangindent=1.27cm \hangafter=0
    \alph{partnumber}) #3
    \par\noindent
    \rule{0pt}{1pt}\hfill(#2 marks)
    \par
    \vspace{5mm}
    \begin{doublespace}
        \foreach \n in {1,\dots,#1}{\rule{\linewidth-1.27cm}{0.5pt}}
        \par
    \end{doublespace} 
}

información relacionada