3

I'm trying to get an exam layout of the form:

1. Blahblahblahblahblahblahblahblah  [ ]
blahblahblahblahblahblahblahblahbla
hblahblahblahblahblahblahblahblah.

where [ ] should be a fairly large (1 cm x 1 cm) square, that is aligned with the first line of each question. I can use exsheets and changepage to produce a list of questions with a proper right margin, but I do not know if I can either use exsheets to define a new question environment that places such box accordingly (I think this should be possible, given the flexibility of the package) or perhaps use another package to achieve this.

Update. I managed to achieve what I intended with the minipage environment. Is there a better option? I still cannot get the first sentence aligned correctly, however.

\documentclass[a4paper,11  pt]{article}
\usepackage[top=2cm, bottom=3cm, left=4cm, right=4cm]{geometry}

\usepackage[utf8x]{inputenc}
\usepackage[spanish]{babel}
\usepackage{varwidth}

\usepackage{lipsum}

\usepackage{fourier}
\usepackage{tgpagella}
\usepackage[T1]{fontenc}

\usepackage{exsheets} 
\SetupExSheets{headings=runin-nr}
\usepackage{setspace}
\onehalfspacing 
\usepackage{etoolbox}
\usepackage{titling}

\setlength{\parindent}{0pt}
\newcommand{\subtitle}[1]{%
    \posttitle{%
        \par\end{center}
        \begin{center}\large#1\end{center}
        \vskip0.5em}%
            }

\title{Title goes here}
\subtitle{Subtitle goes here}
\date{\vspace{-15ex}}

\begin{document}

\maketitle

\hrulefill
\vspace{0.5 em}

    \textsc{Your name}: \dotfill \textsc{Your major:} \dotfill

    \textsc{Your ID}: \dotfill \textsc{Your page tally}: \dotfill

\hrulefill

\vspace{1cm}

\begin{minipage}[t]{.85\textwidth}
    \begin{question} \lipsum[1]
        \end{question}
    \end{minipage}%
\begin{minipage}{.15\textwidth}
    \flushright
        \framebox(20,20){} 
\end{minipage}

\begin{minipage}[t]{.85\textwidth}
    \begin{question} \lipsum[2]
        \end{question}
    \end{minipage}%
\begin{minipage}{.15\textwidth}
    \flushright
        \framebox(20,20){} 
\end{minipage}

    \end{document}

enter image description here

3

No need for putting the question environment in minipages or defining new environments… This is the exsheets way:

\documentclass[a4paper,11pt]{article}
\usepackage[top=2cm, bottom=3cm, left=4cm, right=4cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{tgpagella}
\usepackage[utf8]{inputenc}

\usepackage{exsheets}

\DeclareExSheetsHeadingContainer{square}{\framebox(20,20){}}

\DeclareInstance{exsheets-heading}{custom}{default}{
  runin = true ,
  number-post-code = \space ,
  attach = { main[l,t]square[r,t](\textwidth,0pt) } ,
  join   = { main[r,vc]number[l,vc](0pt,0pt) }
}

\usepackage{scrextend}% provides the addmargin environment
\SetupExSheets{
  headings = custom ,
  question/pre-hook = \addmargin[0pt]{.15\textwidth} ,
  question/post-hook = \endaddmargin
}

\usepackage{lipsum}

\begin{document}

\noindent\hrulefill

\begin{question}
  \lipsum[1]
\end{question}

\begin{question}
  \lipsum[2]
\end{question}

\end{document}

enter image description here


Using xsim (GitHub) – the result looks the same:

\documentclass[a4paper,11pt]{article}
\usepackage[top=2cm, bottom=3cm, left=4cm, right=4cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{tgpagella}
\usepackage[utf8]{inputenc}

\usepackage{xsim,needspace,adjustbox,scrextend}

\xsimsetup{
  exercise/the-counter = \arabic{exercise}. ,
  exercise/template    = square
}

\DeclareExerciseEnvironmentTemplate{square}
  {%
    \Needspace*{2\baselineskip}%
    \addmargin[0pt]{.15\textwidth}%
    \par\noindent
    \adjustbox{
      fbox = 1pt 0pt,
      lap = {\textwidth},
      valign = t,
      set vsize = {0pt}{0pt}
    }{\rule{0pt}{20pt}\hspace{20pt}}%
    \textbf{\GetExerciseProperty{counter}} %
  }
  {\endaddmargin\vspace{\baselineskip}}

\usepackage{lipsum}

\begin{document}

\noindent\hrulefill

\begin{exercise}
  \lipsum[1]
\end{exercise}

\begin{exercise}
  \lipsum[2]
\end{exercise}

\end{document}

BTW: flushright is an environment (\begin{flushright}...\end{flushright}) and not to be used as command (\flushright). The corresponding command is called \raggedleft!

|improve this answer|||||
1

For the correct alignment you can play with minipage options.

For convenience, I've created a new enviroment (but nesting environments are too much above my level of knowledge, hence you have to use question environment within mine).

\documentclass[a4paper,11  pt]{article}
\usepackage[top=2cm, bottom=3cm, left=4cm, right=4cm]{geometry}
\usepackage[utf8x]{inputenc}
\usepackage[spanish]{babel}
\usepackage{varwidth}

\usepackage{lipsum}

\usepackage{fourier}
\usepackage{tgpagella}
\usepackage[T1]{fontenc}

\usepackage{exsheets} 
\SetupExSheets{headings=runin-nr}
\usepackage{setspace}
\onehalfspacing 
\usepackage{etoolbox}
\usepackage{titling}

\setlength{\parindent}{0pt}
\newcommand{\subtitle}[1]{%
    \posttitle{%
        \par\end{center}
    \begin{center}\large#1\end{center}
    \vskip0.5em}%
}

\title{Title goes here}
\subtitle{Subtitle goes here}
\date{\vspace{-15ex}}
\newenvironment{myquest}{%
\begin{minipage}[t][\height][t]{.85\textwidth}
}{%
\end{minipage}%
\begin{minipage}[t][26pt][b]{.15\textwidth}
    \raggedleft
    \framebox(20,20){} 
\end{minipage}
\vspace{\baselineskip}
}

\begin{document}

\maketitle

\hrulefill
\vspace{0.5 em}

\textsc{Your name}: \dotfill \textsc{Your major:} \dotfill

\textsc{Your ID}: \dotfill \textsc{Your page tally}: \dotfill

\hrulefill
\vspace{1cm}
\begin{myquest}
    \begin{question} 
        \lipsum[1]
    \end{question}
\end{myquest}

\begin{myquest}
    \begin{question} 
        \lipsum[2]
    \end{question}
\end{myquest}

\end{document}

enter image description here

It's likely there's a better solution using exsheets options, but I don't know that package, maybe I'll edit my answer after reading its documentation (if someone else doesn't answer before me).

Edit: see clemens's answer for an exsheets solution.

|improve this answer|||||

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.