5

I'm attempting to create a template for writing up Physics problems sets. A lot of these problem sets can involve short, simple calculations. For example:

simple calculation

I attempt to typeset this calculation with something like

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{enumerate}
\item
\begin{align*}
\omega_{0}&=\sqrt{k_{0}/M}\\
&=\sqrt{5/10}\\
&=\frac{1}{\sqrt{2}}
\end{align*}
\end{enumerate}
\end{document}

But the result ends up looking something like this:

damn

Which looks terrible to me - it's such a short calculation, it looks absurd slapped in the center of the document like that, especially without any text before or after.

Alternatively, I can just use the inline equation form,

\documentclass{article}
\begin{document}
\begin{enumerate}
\item
$\omega_{0}=\sqrt{k_{0}/M}$\\
$=\sqrt{5/10}$\\
$=\frac{1}{\sqrt{2}}$
\end{enumerate}
\end{document}

But that yields something like this, which loses the nice formatting of an equation array.

damn again

Essentially, what I'm aiming for is a way to typeset the equation as though it were just inline text (i.e. with the $\omega_{0}$ coming directly after the 1., as in the inline form), but preserving the alignment and formatting of an equation array. The closest I've gotten was with the fleqn option and a negative \vspace to put it on the same line, but even that didn't look right, as fleqn just makes the equation more leftward, but doesn't actually align it with the margin of the text.

1
  • Don't do it like this: if it's an inline equation, then let it be an inline equation.
    – egreg
    Commented Jan 10, 2014 at 12:05

2 Answers 2

6

In-line math mode is the way to go. But you will need the aligned environment from »amsmath«. You can align it to the top with respect to the current line.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}  % loads »amsmath«

\begin{document}
  \begin{enumerate}
    \item
      \(
        \begin{aligned}[t]
          \omega_{0} &= \sqrt{k_{0}/M}\\
                     &= \sqrt{5/10}\\
                     &= \frac{1}{\sqrt{2}}
        \end{aligned}
      \)
  \end{enumerate}
\end{document}

enter image description here

3
  • The square root symbol looks "broken". Do you know if this is an issue with the font? Commented Jan 10, 2014 at 11:06
  • That's perfect! I had tried aligned, but I wasn't aware of the [t] option, so it didn't line up with the text the way I wanted it to. And Svend, I see that too, but I didn't do that when I typeset the equation, so I think that's just an issue with whatever pdf viewer the image was rendered in - I've seen similar problems with TeXShop's built in pdf view.
    – TheMac
    Commented Jan 10, 2014 at 21:53
  • 1
    @SvendTveskæg: An issue with the viewer at the chosen magnification. In other levels of magnification it renders fine. The printed output should not be affected. Commented Jan 11, 2014 at 8:11
1

For these kind of short derivations, a stack can frequently accomplish what you need. In this case, I set the stackgap to 4pt for demonstration purposes (the default is 3pt) and invoke the stack with left alignment.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\stackMath
\setstackgap{S}{4pt}
\begin{document}
1. $
\omega_o \mathrel{\Shortunderstack[l]{= \sqrt{k_0/M}\\= \sqrt{5/10}\\
  = \displaystyle\frac{1}{\sqrt{2}}}}
$
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .