1

I'm new to LaTeX but want to use it to set test papers.

My current code outputs my exam questions like this.

enter image description here

However, I want to increase the horizontal spacing between the question number and the question, as well as the option number and the option. I managed to achieve it somewhat by manually adding in \hspace{0.2cm}.

enter image description here

I was wondering if there was a way to change it such that I don't need to manually input \hspace{0.2cm} every time? Such as changing the command of \question itself. Is that possible?

My current code is as follows:

% !TEX program = xelatex

\documentclass[addpoints]{exam}
\usepackage{fontspec}
\usepackage{geometry}
\usepackage[version=4]{mhchem}
 
\setmainfont{Arial}
\title{Sample Exam}
\geometry{a4paper, portrait, margin=1in}
   
\renewcommand{\choicelabel}{\textbf{\thechoice}}

\renewcommand{\questionlabel}{\textbf{\thequestion}}

\renewcommand{\partlabel}{\textbf{(\thepartno)}}

\renewcommand{\subpartlabel}{\textbf{(\thesubpart)}}

\renewcommand{\choiceshook}{%
    \setlength{\leftmargin}{1.2cm}%
}

\setlength\dottedlinefillheight{.4in}

\renewcommand{\questionshook}{\setlength{\itemsep}{2em}}
\renewcommand{\partshook}{\setlength{\itemsep}{1em}}
\renewcommand{\subpartshook}{\setlength{\itemsep}{1em}}

\begin{document}

\begin{questions}
  
    \question \hspace{0.2cm}
    Which statement about $\ce{^{35}_{17}Cl}$ and $\ce{^{37}_{17}Cl}$ is correct?
    \begin{choices}
        \choice \hspace{0.2cm} They have the same number of electrons and protons.
        \choice \hspace{0.2cm} They have the same number of neutrons and electrons.
        \choice \hspace{0.2cm} They have the same number of neutrons and protons.
        \choice \hspace{0.2cm} They have the same number of nucleons and electrons.
    \end{choices}

\end{questions}

\end{document}

Thanks!

1
  • The \leftmargin is set before \questionhook, so changing \labelsep is too late. OTOH, the drefault is \settowidth{\leftmargin}{10.\hskip\labelsep}. Jul 18, 2023 at 13:31

1 Answer 1

1

According to the user manual, the environments questions and choices are implemented as LaTeX list environments and you can set the list parameters by using the corresponding \...hook commands.

enter image description here

% !TEX program = xelatex

\documentclass[addpoints]{exam}
\usepackage{fontspec}
\usepackage{geometry}
\usepackage[version=4]{mhchem}
 
\setmainfont{Arial}
\title{Sample Exam}
\geometry{a4paper, portrait, margin=1in}
   
\renewcommand{\choicelabel}{\textbf{\thechoice}}

\renewcommand{\questionlabel}{\textbf{\thequestion}}

\renewcommand{\partlabel}{\textbf{(\thepartno)}}

\renewcommand{\subpartlabel}{\textbf{(\thesubpart)}}

\renewcommand{\choiceshook}{%
  \addtolength{\labelsep}{0.2cm}}
\renewcommand{\questionshook}{%
  \addtolength{\labelsep}{0.2cm}}

\setlength\dottedlinefillheight{.4in}

\renewcommand{\partshook}{\setlength{\itemsep}{1em}}
\renewcommand{\subpartshook}{\setlength{\itemsep}{1em}}

\begin{document}

\begin{questions}
  
    \question
    Which statement about $\ce{^{35}_{17}Cl}$ and $\ce{^{37}_{17}Cl}$ is correct?
    \begin{choices}
        \choice They have the same number of electrons and protons.
        \choice They have the same number of neutrons and electrons.
        \choice They have the same number of neutrons and protons.
        \choice They have the same number of nucleons and electrons.
    \end{choices}

\end{questions}

\end{document}
0

You must log in to answer this question.

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