Document ClassesSmall problem with exam class

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small problem with exam class

Post by Cham »

I'm using the exam class and need to move some parts to the left margin. Here's a complete MWE to show my problem :

Code: Select all

\documentclass[11pt]{exam}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage[margin=1in]{geometry}

\newcommand{\class}{Class title}
\newcommand{\term}{Winter 2015}
\newcommand{\examnum}{Test 1}

\begin{document}

\pagestyle{head}
\runningheadrule
\firstpageheader{\textbf{\textsl{\textsf{Class title}}}}{\Large{\textbf{\textsf{Test 1}}}}{\large{\textsf{Winter 2015}}}\runningheader{\textsl{Class title}}{Winter 2015}{Page \thepage\ of \numpages}

\begin{minipage}[t]{6.5in}

\textsf{Name:} \makebox[2.5in]{\hrulefill}
\medskip\medskip

\textbf{If you want to be successfull:}
\medskip
\begin{itemize}
	\item A directive.
	\medskip
	\item Another directive.
	\medskip
	\item A directive again.
	\medskip
	\item Yet another directive.
	\medskip
	\item You will fail anyway!
\end{itemize}
\medskip
\end{minipage}
\rule[1ex]{\textwidth}{0.1pt}

\begin{questions}

\addpoints
\question[2] A question.

\question[5] Another question.

\newpage
\question[10] Calculate $f(x) = x^2$ from $x = 1$ ?

\newpage
\question[10] Consider this $f(x) = x^2$.


\end{questions}

\end{document}
Here's a preview of the first page :
exam.jpg
exam.jpg (28.8 KiB) Viewed 4593 times
I need to push the name field and the next line to the left margin. What is the proper way to do that ? Adding the command \noindent works for the name field, but do nothing for the next line (defined in a minipage).

Also, I would like to see the page number alternated left-right in the header, depending on the page number, since the document would be printed on both sides of the paper.

(and why is the overleaf preview so long ?).

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small problem with exam class

Post by Cham »

I found a solution to the alternate left-right pages in the header.

I just have to change the runningheader with this code :

Code: Select all

\runningheader{\oddeven{Winter 2015}{Page \thepage\ of \numpages}}%
	{Title}%
	{\oddeven{Page \thepage\ of \numpages}{Winter 2015}}
But I still need to push the first line in the directives, to the left margin. Any idea ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Small problem with exam class

Post by Johannes_B »

The second part you were able to figure out yourself, the first part is much more easier though. What you see there, is the parindent. You can remove it by using \noindnet, as you already figured out.

The thing is, LaTeX sees the minipage as one single letter (box), you need to issue \noindent just before the minipage. Doing it inside should not have any effect, a minipage sets the parindent to zero by default.

As you are typesetting an exsheet, you can just as well set the parindent globally to zero.
\setlength{\parindent}{0pt}
But please, never do that for a scientific text.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply