Math & ScienceAlignement problem in exam class

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Alignement problem in exam class

Post by Cham »

I'm having some troubles in aligning some simple equations. Here's the MWE code to explain my issue, and a preview :

Code: Select all

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

\begin{document}
\begin{questions}
\question[10] Some equations to solve :

\medskip

\begin{parts}
	\part
		\setlength{\abovedisplayskip}{0pt}
		\begin{flalign*}
			5 x + 2 y &= 3 y, & \\
			(x + y) + 2 x &= 4 x + y.
		\end{flalign*}
	\vfill
	\part
		\begin{flalign*}
			x + 2 y &= 3 y, & \\
			2 x + y &= 2.
		\end{flalign*}
	\vfill
	\part
		\begin{flalign*}
			x + y &= 5, & \\
			y &= 1.
		\end{flalign*}
	\vfill
\end{parts}

\end{questions}
\end{document}
Preview :
2equs.jpg
2equs.jpg (12.89 KiB) Viewed 3306 times
I need the equations sets to be aligned with their left letter, and on the left side of the page. Currently, the flalign command doesn't seem to work. How to fix that ?
Last edited by Cham on Sun May 20, 2018 1:06 am, edited 1 time in total.

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

Alignement problem in exam class

Post by Cham »

Weird ! Adding & at the end of the first equation line solves the left flushing issue. Why ?

Code: Select all

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

\begin{document}
\begin{questions}
\question[10] Some equations to solve :

\begin{parts}
	\part
		\begin{flalign*}
			5 x + 2 y &= 3 y, & \\
			(x + y) + 2 x &= 4 x + y.
		\end{flalign*}
	\vfill
	\part
		\begin{flalign*}
			x + 2 y &= 3 y, & \\
			2 x + y &= 2.
		\end{flalign*}
	\vfill
	\part
		\begin{flalign*}
			x + y &= 5, & \\
			y &= 1.
		\end{flalign*}
	\vfill
\end{parts}

\end{questions}
\end{document}
Now, how to make the set of equations to be centered on its left letter ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Alignement problem in exam class

Post by Cham »

I've found an hack, but I don't think this is a good way of doing this. Is there a "local" way of reducing the vertical space between the text and the aligned equations ? I don't want the command to change everything in the whole document :

Code: Select all

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

\begin{document}
\begin{questions}
\question[10] Some equations to solve :

\medskip

\begin{parts}
	\part
		\setlength{\abovedisplayskip}{0pt} % <=== stupid hack ?
		\begin{flalign*}
			5 x + 2 y &= 3 y, & \\
			(x + y) + 2 x &= 4 x + y.
		\end{flalign*}
	\vfill
	\part
		\begin{flalign*}
			x + 2 y &= 3 y, & \\
			2 x + y &= 2.
		\end{flalign*}
	\vfill
	\part
		\begin{flalign*}
			x + y &= 5, & \\
			y &= 1.
		\end{flalign*}
	\vfill
\end{parts}

\end{questions}
\end{document}
Post Reply