5

I am writing my exam paper in LaTeX. I have just a small enquiry. The code I am using is:

\documentclass[12pt,paper=a4,answers, addpoints]{exam}
\usepackage{graphicx,lastpage}
\usepackage{upgreek}
\usepackage{censor}
\usepackage{amsmath}
\usepackage{eurosym}
\censorruledepth=-.2ex
\censorruleheight=.1ex
\hyphenpenalty 10000
\usepackage[paperheight=10.5in,paperwidth=8.27in,bindingoffset=0in,left=0.8in,right=1in,
top=1in,bottom=1in,headsep=1.5\baselineskip]{geometry}
\flushbottom
\usepackage[normalem]{ulem}
\usepackage[utf8]{inputenc}
\renewcommand\ULthickness{2pt} %%---> For changing thickness of underline
\setlength\ULdepth{1.5ex}%\maxdimen ---> For changing depth of underline
\renewcommand{\baselinestretch}{1}
\pagestyle{empty}

\pagestyle{headandfoot}
\headrule
\newcommand{\continuedmessage}{%
\ifcontinuation{\footnotesize Question \ContinuedQuestion\ continues\ldots}{}%
}
\runningheader{\footnotesize Dipartimento di Economia}
{\footnotesize Economia Pubblica -- L33}
{\footnotesize Pagina \thepage\ di \numpages}
\footrule
\footer{\footnotesize}
{}
{\ifincomplete{\footnotesize Question \IncompleteQuestion\ Continua nella pagina successiva}{\iflastpage{\footnotesize \textit{\bfseries Fine domande di esame}}{\footnotesize \textit{\bfseries Continua nella pagina successiva}}}}

\usepackage{cleveref}
\crefname{figure}{figure}{figures}
\crefname{question}{question}{questions}
\renewcommand\thequestion{\arabic{question}}
\renewcommand{\questionlabel}{\thequestion)}
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}

\nopointsinmargin 
\pointpoints{Punto}{Punti}

\marginpointname{\points}
\pointformat{\boldmath\themarginpoints}
\bracketedpoints

\begin{document}

\thispagestyle{empty}

\noindent
\begin{minipage}[t]{\textwidth}%
\centering
\includegraphics[width=1.5cm]{logo} \par
\textit{\textbf{University of XXX}}\par
\textit{\textbf{Dipartiment  of XXX}} \par
\smallskip
\textit{\textbf{Seconda Sessione \\ Terzo Appello}} 
\end{minipage}
\par
\bigskip\bigskip
\begin{minipage}[t]{.5\textwidth}%
{\bfseries Corso di Studio}: First course \\ Second course\\ Third Course \par
\vspace{1ex}
{\bfseries Codice del corso di laurea}: XXX\par
\vspace{1ex}
{\bfseries Materia}: XXXX \par
\vspace{1ex}
{\bfseries Data}: XXX \par
\vspace{1ex}
{\bfseries Docente}: XXX
\end{minipage}%
\hfill
\begin{minipage}[t]{.4\textwidth}%
{\bfseries Nome}: {\hrulefill} \par
\vspace{1ex} 
{\bfseries Matricola}: {\hrulefill} \par
\vspace{1ex}
{\bfseries Documento}: {\hrulefill} \par
\vspace{1ex}
{\bfseries Durata}: 1.5 h + 10 minuti di lettura\par
\vspace{1ex}
{\bfseries Firma}:{\hrulefill} 
\end{minipage}
\par
\bigskip
\begin{center}
\rule{\textwidth}{1pt}
\end{center}
\bigskip
\end{document}

The result is:

enter image description here

Basically, I would like to align "Second Course" and "Third Course" under "First Course".

Do you have any suggestion?

Thanks.

  • Put the whole in a tabular environment. – Bernard May 20 '16 at 21:52
  • Please(!) comment all non-necessary packages out. This is not a MWE. – MaestroGlanz May 21 '16 at 8:34
6

tabular for the course

The three courses can be put in a tabular:

\textbf{Corso di Studio:}
\begin{tabular}[t]{@{}l@{}}
  First course\\
  Second course\\
  Third course\\
\end{tabular}

Result

tabularx with two columns

X column type is a p column type, which uses the available space.

\documentclass{article}
\usepackage{tabularx}

\begin{document}
\noindent
\begin{minipage}{.5\textwidth}
\begin{tabularx}{\linewidth}{@{}l@{ }X@{}}
  \bfseries Corso di Studio:&
  First course\newline
  Second course\newline
  Third course
\end{tabularx}
\end{minipage}
\end{document}

Courses set in varwidth

Environment varwidth is similar to minipage or \parbox, but the specified width is only a maximum width. If the contents is smaller, then the result uses the smaller width.

\documentclass{article}
\usepackage{varwidth}

\begin{document}
\noindent
\textbf{Corso di Studio:}
\begin{varwidth}[t]{\linewidth}% truncated to the needed space
  First course\\
  Second course\\
  Third course
\end{varwidth}
\end{document}
5

I suggest you replace

\par
\bigskip\bigskip
\begin{minipage}[t]{.5\textwidth}%
{\bfseries Corso di Studio}: First course \\ Second course\\ Third Course \par
\vspace{1ex}

with

\par
\bigskip\bigskip
\noindent  % <--- new
\begin{minipage}[t]{.5\textwidth}%
{\bfseries Corso di Studio}: 
\parbox[t]{4cm}{First course \\ 
                Second course\\ 
                Third Course }
\par\bigskip

Observe the use of a \parbox macro. Furthermore, note the new \noindent instruction just ahead of \begin{minipage}.

enter image description here

  • @Heiko Oberdiek. Thank you very much for your help. Also thanks to Mico – Dario May 20 '16 at 22:03
1

Jus fort fun, without tabular, without minipage and without ubiquitous \vspace{1ex}:

mwe

\documentclass[12pt,paper=a4,answers, addpoints]{exam}
\usepackage{tabto,graphicx}
\TabPositions{0pt, 0.23\linewidth,  0.5\linewidth}
\begin{document}
{\obeylines{\centering
\includegraphics[width=5em]{mesina.png}
\em\bfseries
University of XXX
Dipartiment of XXX \smallskip
Seconda Sessione
Terzo Appello
}
\bigskip\bigskip
\parskip1ex\parindent0pt
{\bfseries Corso di Studio}: \tab First course \tab {\bfseries Nome}: \dotfill
     \tab Second course\tab {\bfseries Matricola}: \dotfill
     \tab Third Course \tab {\bfseries Documento}:  \dotfill
{\bfseries Codice del corso di laurea}: XXX
{\bfseries Materia}: XXXX
{\bfseries Data}: XXX 
{\bfseries Docente}: XXX
{\bfseries Durata}: 1.5 h + 10 minuti di lettura \tab {\bfseries Firma}: \hrulefill
\bigskip\bigskip
\rule{\textwidth}{1pt}}
\bigskip\bigskip
\begin{questions}
\question[10] What is this ?
\begin{solution} Another way. \end{solution}
\end{questions}
\end{document}

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.