General ⇒ aligning equations and spacing with inparaenum
aligning equations and spacing with inparaenum
1) aligning equations. I know the basic of the align and eqnarray environments, but I need to fine tune a bit.
2) spacing between inparaenum items
I am writing the solution set for some math problems, and each problem is numbered, and then has subsections with letters, so I am using nested enumerates. Like this:
8. (a) ....
Generally I have the solution start immediately after the letter. In some situations I have several lines of equations that i would like to align around the equal sign. I tried using both the align and eqnarray environments, but they both had the same problem ... they centered the equations on the page and skipped the first line.
I would like the first like to appear right after the letter:
8. (a) cos x = ....
and have the equations under it align with that equal sign (the first equation can be moved to the right a little if necessary for alignment purposes, but not centered).
How do I do this?
The second question is that when I have a bunch of short answers for a problem, I would like them to be listed in line instead vertically.
I found inparaenum that does this, but it puts too little space between the elements in the list. I had to add the space manually. Is there a way to set the default spacing used?
For example, by default I get something like this:
2. (a) cos 45 (b) sin 30 (c) tan 90
and I want something more like this:
2. (a) cos 45 (b) sin 30 (c) tan 90
Thanks for any help I can get.
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
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
aligning equations and spacing with inparaenum
My idea concerning your equation alignment is: use the fleqn-Option of amsmath for left alignment and change some predefined lengths to get the result. Define your own align-environment:
Code: Select all
\usepackage[fleqn]{amsmath}
\newenvironment{myalign}{%
\setlength{\mathindent}{0pt}%
\setlength{\abovedisplayskip}{-\baselineskip}%
\setlength{\abovedisplayshortskip}{\abovedisplayskip}%
\align
}%
{\endalign}
...
\begin{enumerate}
\item \begin{myalign}
... \end{myalign}
...
Re: aligning equations and spacing with inparaenum
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
aligning equations and spacing with inparaenum
here is the modification for a starred myalign-environment:
Code: Select all
\makeatletter
\newenvironment{myalign*}{%
\setlength{\mathindent}{0pt}%
\setlength{\abovedisplayskip}{-\baselineskip}%
\setlength{\abovedisplayshortskip}{\abovedisplayskip}%
\start@align\@ne\st@rredtrue\m@ne
}%
{\endalign}
\makeatother
Re: aligning equations and spacing with inparaenum
Now if only someone had an equally good solution to the inparaenum problem ...
Re: aligning equations and spacing with inparaenum
B.A.
aligning equations and spacing with inparaenum
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\usepackage{paralist}
\newenvironment{myinparaenum}%
{\begin{inparaenum}[\hspace{2em}(a)]\hspace{-2em}\ignorespaces}%
{\end{inparaenum}}
\begin{document}
\begin{enumerate}
\item $\begin{aligned}[t]
a&=b+c+d+e+f+g+h+i \\
&=j+k+l+m+n+p \\
&=q+r+s+t
\end{aligned}$
\item \begin{inparaenum}[(a)]
\item $\sin \pi/4$ \item $\cos \pi/7$ \item $\tan 3\pi/5$
\end{inparaenum}
\item \begin{myinparaenum}
\item $\sin \pi/4$ \item $\cos \pi/7$ \item $\tan 3\pi/5$
\end{myinparaenum}
\end{enumerate}
\end{document}
Concerning the space between in a inparaenum environment, it can be increased with \hspace, considering that space as part of the item label. See the above definition of myinparaenum. You can replace both instances of 2em by a length suiting your needs.
Re: aligning equations and spacing with inparaenum
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Re: aligning equations and spacing with inparaenum
this is really an elegant approach!
I like amsmath for its flexible environments, so why not take some more time to choose the environment more carefully to meet the requirements, next time for me... instead of beginning to program a workaround.

Stefan
Re: aligning equations and spacing with inparaenum
By the way, the {aligned}[t] environment was great. Thanks.