2

This may be bad typesetting, but I'm working with limited resources where I both want and need to conserve paper. This is not something for publication, so the standards for a math paper need not apply. This is for a high school math class.

I would like to create something that looks like:

enter image description here

which I'm able to do with a bit of finagling via

\documentclass{article}
\usepackage[textwidth=4in]{geometry}
\setlength\parskip{2ex}
\setlength\parindent{0pt}
\usepackage{amsmath}
\newcounter{ae@problem}
\newcommand\problem{\stepcounter{ae@problem}\textbf{P\arabic{ae@problem}}\hspace*{1em}}
\begin{document}

There is one mistake in each of the problems.  Identify the mistake by
circling it.  Then correct the work.

\problem 
\begin{minipage}[t]{2.5in}
\vspace{-\dimexpr\abovedisplayskip+\abovedisplayshortskip+\baselineskip}
\begin{align*}
  \text{For } h(x) &= x^{2}+2x+4 \\
  h(-3) &= -3^{2}+2(-3)+4 = -9-6+4 \\&= -15 + 4 = -11
\end{align*}
\end{minipage}

\end{document}

Is there an easier approach or an alignment environment which is better suited to this purpose?

I would like the first line of the text to line up as in this approach:

\documentclass{article}
\usepackage[textwidth=4in]{geometry}
\setlength\parskip{2ex}
\setlength\parindent{0pt}
\usepackage{amsmath}
\newcounter{ae@problem}
\newcommand\problem{\stepcounter{ae@problem}\textbf{P\arabic{ae@problem}}\hspace*{1em}}
\begin{document}

There is one mistake in each of the problems.  Identify the mistake by
circling it.  Then correct the work.

\problem For $h(x) = x^{2}+2x+4$.
\begin{align*}
  h(-3) &= -3^{2}+2(-3)+4 = -9-6+4 \\&= -15 + 4 = -11
\end{align*}

\end{document}

enter image description here

But I don't like how the align environment's first equal sign is misaligned with the presentation of the function on the first line.

A.Ellett
  • 50,533

2 Answers2

2

problem with solution

\documentclass{article}
\usepackage[textwidth=4in]{geometry}
\setlength\parskip{2ex}
\setlength\parindent{0pt}
\usepackage{amsmath}
\newcounter{ae@problem}
\newcommand\problem{\stepcounter{ae@problem}\textbf{P\arabic{ae@problem}}\hspace*{1em}}
\begin{document}

There is one mistake in each of the problems.  Identify the mistake by
circling it.  Then correct the work.
\begin{flalign*}
\textrm{\problem For } h(x) &= x^{2}+2x+4 &\\[\parskip]
  h(-3) &= -3^{2}+2(-3)+4 = -9-6+4 &\\
  &= -15 + 4 = -11 &
\end{flalign*}

\end{document}

Of course, it you put flaign at the start of a paragraph, the space will be too big. There are several ways to fix that, none of which are ideal.

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • The solution is good, apart from abuse of \parskip. – egreg Sep 17 '15 at 22:35
  • @egreg - I'm not even sure he wanted extra space there. – John Kormylo Sep 17 '15 at 22:48
  • @egreg The \parskip is my issue not JohnKormylo's. I'll take the blame for that. And I'm aware of the issues around it but I haven't found a solution which works adequately for the sorts of documents I create. There's a lot of abuse of various standards for typesetting in my documents, but I feel there are other more pressing issues. – A.Ellett Sep 17 '15 at 22:48
  • @A.Ellett Be virtually slapped. – egreg Sep 17 '15 at 22:49
  • @egreg Ah, but I thought you were referring to the \setlength\parskip{2ex}, which, if you were, I am virtually slapped. But I just noticed the odd \\[\parskip] which is certainly not me and not how I would approach it. :-) – A.Ellett Sep 17 '15 at 22:53
  • Why it didn't occur to me to use falign, I do not know. I just don't write that much that needs such kind of alignments (mostly geometry stuff here for high schoolers). The extra space at the start of the paragraph is something easy enough for me to clean. Thank you for your solution. – A.Ellett Sep 17 '15 at 22:55
0

Here's another option that uses a form of \tag for the placement of the problem:

enter image description here

\documentclass{article}
\usepackage[textwidth=4in]{geometry}% Just for this example
\usepackage{amsmath}

\makeatletter% http://tex.stackexchange.com/a/193538/5764
\newcommand{\leqnomode}{\tagsleft@true}
\newcommand{\reqnomode}{\tagsleft@false}
\makeatother

\newcounter{problemcnt}
\newenvironment{problem}
  {\leqnomode
   \refstepcounter{problemcnt}%
   \csname align*\endcsname% http://tex.stackexchange.com/a/13994/5764
     \tag*{\bfseries P\theproblemcnt}
  }{%
    \csname endalign*\endcsname
    \reqnomode}
\begin{document}

There is one mistake in each of the problems.  Identify the mistake by
circling it. Then correct the work.
\begin{problem}
  \text{For } h(x) &= x^{2}+2x+4 \\
             h(-3) &= -3^{2}+2(-3)+4 = -9-6+4 \\
                   &= -15 + 4 = -11
\end{problem}

\end{document}
Werner
  • 603,163
  • This is more like what I wanted to do in terms of the LaTeX coding, but is there a way to better control the distance between the problem number and the word For? – A.Ellett Sep 18 '15 at 01:46
  • @A.Ellett: Do you want the problem number closer to the formula, or the formula closer to the problem number? – Werner Sep 20 '15 at 05:45
  • I'd like to have a way to control or set the length of the space between the tag and the start of the formula. – A.Ellett Sep 26 '15 at 21:48