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 3450 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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
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