3

I am making a test. Some of the problems have choices, and the choices are mathematical expressions. I have included the code for the first two problems; 1.) has six choices, and 2.) has eight choices. The choices are labeled as "i.)", "ii.)", ... "viii.)". I want the first right parenthesis in each row to be aligned vertically. So, I want the ")" in "i.)" and "iv.)" from 1.) to be aligned with the ")" in "i.)" and "v.)" from 2.).

The code that I provide does have the ")" aligned vertically within each problem. Now I would like to add one extra feature - the first ")" in all the rows to be the same distance from the left margin. (I guess that a distance of "4em" would be appropriate.)

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}


    \begin{document}

    \noindent {\bf 1.)} Which of the following functions is graphed?
    \begin{alignat*}{6}
    {\mathrm{i.})} \ &y = (x + 5)^{2}
    \qquad \quad
    &{\mathrm{ii.})} \ &y = \sqrt{x + 5}
    \qquad \quad
    &{\mathrm{iii.})} \ &x = y^{2} + 5
    \\
    {\mathrm{iv.})} \ &y = \frac{\sqrt{x^{2} - 25}}{\sqrt{x - 5}}
    \qquad \quad
    &{\mathrm{v.})} \ &y = \frac{1}{\sqrt{x + 5}}
    \qquad \quad
    &{\mathrm{vi.})} \ &\vert x \vert = y^{2} + 5
    \end{alignat*}
    \vskip0.25in
    \hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
          xmax=26,ymax=7,
          axis lines=middle,
          restrict y to domain=-3:6.5,
          enlargelimits={abs=1cm},
          axis line style={latex-latex},
          ticklabel style={fill=white},
          ytick=\empty,
          xtick={-5,5}
]
\addplot[domain=5:26,mark=none,samples=201] {sqrt(x + 5)};
\addplot[domain=-6:5,dashed,thin,mark=none,samples=201] {sqrt(x + 5)};

\draw [densely dashed] (5,3.16227766) -- (5,0);
\draw [fill=white] (5,3.16227766) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}
\hspace{\fill}
\vskip0.25in

\noindent {\bf 2.)} Which of the following products is equal to an integral power of 10?
\begin{alignat*}{8}
{\mathrm{i.})} \ &1
\qquad \quad
&{\mathrm{ii.})} \ &5^{-3}\left(\frac{1}{8}\right)
\qquad \quad
&{\mathrm{iii.})} \ &5^{-3}\left(\frac{1}{80}\right)
\qquad \quad
&{\mathrm{iv.})} \ &5^{-3}\left(\frac{1}{800}\right) \\
{\mathrm{v.})} \ &\left(\frac{4}{9}\right)^{3}15^{6}
\qquad \quad
&{\mathrm{vi.})} \ &2^{-6}25^{-3}
\qquad \quad
&{\mathrm{vii.})} \ &\left(\frac{1}{2}\right)^{6}\left(\frac{1}{25}\right)^{3}
\qquad \quad
&{\mathrm{viii.})} \ &\left(\frac{7}{4}\right)^{6}\left(\frac{1}{5^{4}49}\right)^{3}
\end{alignat*}
\vskip0.25in


\end{document}
8
  • If this is for an exam, there are packages that allow you create answers with option easily.
    – Aradnix
    Sep 20, 2014 at 22:33
  • 1
    Or enumitem for control over enumerations if you just want something simple. Don't use commands such as \bf, though, they are deprecated (from LaTeX 2.09!). Use e.g. \bfseries (or \textbf{}) instead.
    – cfr
    Sep 20, 2014 at 23:04
  • \makebox[3em][r]{viii)} is a simple replacement. Sep 21, 2014 at 14:23
  • @John Kormylo Since the choices may involve fractions and rational functions, commands involving makebox have to be in an align environment. How do I use your command in an align environment so that the ")" in "i.)" and "iv.)" are 3em from the left margin?
    – user143462
    Sep 21, 2014 at 15:35
  • @cfr I want to enumerate in a particular way. Can you give me a link for enumitem?
    – user143462
    Sep 21, 2014 at 15:36

2 Answers 2

1

This is easy with the tablists package and also the syntax is much friendler.

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepackage{tablists,enumitem,amsmath}

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}


\begin{document}
\begin{enumerate}[label=\bfseries\arabic*.,leftmargin=*]
\item Which of the following functions is graphed?

  \medskip

  \begin{tabenum}[i.)]
  \tabenumitem $y = (x + 5)^{2}$
  \tabenumitem $y = \sqrt{x + 5}$
  \tabenumitem $x = y^{2} + 5$
  \\[1ex]
  \tabenumitem $y = \dfrac{\sqrt{x^{2} - 25}}{\sqrt{x - 5}}$
  \tabenumitem $y = \dfrac{1}{\sqrt{x + 5}}$
  \tabenumitem $\lvert x \rvert = y^{2} + 5$
  \end{tabenum}

  \begin{center}
  \begin{tikzpicture}
  \begin{axis}[width=4in,axis equal image,
          xmax=26,ymax=7,
          axis lines=middle,
          restrict y to domain=-3:6.5,
          enlargelimits={abs=1cm},
          axis line style={-latex},
          ticklabel style={fill=white},
          ytick=\empty,
          xtick={-5,5}
  ]
  \addplot[domain=5:26,mark=none,samples=201] {sqrt(x + 5)};
  \addplot[domain=-6:5,dashed,thin,mark=none,samples=201] {sqrt(x + 5)};

  \draw [densely dashed] (5,3.16227766) -- (5,0);
  \draw [fill=white] (5,3.16227766) circle [radius=1.5pt];
  \end{axis}
  \end{tikzpicture}
  \end{center}

\item Which of the following products is equal to an integral power of $10$?

  \medskip

  \begin{tabenum}[i.)]
  \tabenumitem $1$
  \tabenumitem $5^{-3}\left(\dfrac{1}{8}\right)$
  \tabenumitem $5^{-3}\left(\dfrac{1}{80}\right)$
  \tabenumitem $5^{-3}\left(\dfrac{1}{800}\right)$ 
  \\[1ex]
  \tabenumitem $\left(\dfrac{4}{9}\right)^{3}15^{6}$
  \tabenumitem $2^{-6}25^{-3}$
  \tabenumitem $\left(\dfrac{1}{2}\right)^{6}\left(\dfrac{1}{25}\right)^{3}$
  \tabenumitem $\left(\dfrac{7}{4}\right)^{6}\left(\dfrac{1}{5^{4}49}\right)^{3}$
  \end{tabenum}
\end{enumerate}

\end{document}

enter image description here

0

I adopted a tabstack approach to solving the problem. Changes to your MWE included:

1) Replacing

\begin{alignat*}{8}...\end{alignat*}

with

\[ \makebox[\textwidth][l]{\kern4em\alignShortstack{...}}\]

It has the effect of indenting the aligned Shortstack 4em from the left margin;

2) Replacing all your \ & with &\; and

3) Using an \llap on the first roman-numeral label on each row. Since the width of the "i) iv)" labels is wider than the width of the "i) v)" labels, and the OP wanted the right parens to align in the first column at 4em, I had to make the labels of column 1 all of zero width, which I did with an \llap.

Other parameter definitions employed in the preamble as follows:

  • \stackMath will make the \alignShortstack arguments to be processed in math mode;

  • \setstackgap{S}{10pt} sets the gap between answer rows to be 10pt;

  • \setstackaligngap{3em} changes the default horizontal spacing between columns (and was thus used to eliminate all your quads and \qquads); and

  • \renewcommand\TAB@delim[1]{\displaystyle#1} is an undocumented way to force all TABstack arguments to be processed in \displaystyle.

Here is the revised MWE:

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
%\pgfplotsset{compat=1.11}
\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}

\usepackage{tabstackengine}
\stackMath
\setstackgap{S}{10pt}
\setstackaligngap{3em}
\makeatletter
\renewcommand\TAB@delim[1]{\displaystyle#1}%
\makeatother

    \begin{document}

    \noindent {\bf 1.)} Which of the following functions is graphed?
\[ \makebox[\textwidth][l]{\kern4em\alignShortstack{
    \llap{i.)} &\ y = (x + 5)^{2}
    &{\mathrm{ii.})} &\ y = \sqrt{x + 5}
    &{\mathrm{iii.})} &\ x = y^{2} + 5
    \\
    \llap{iv.)} &\ y = \frac{\sqrt{x^{2} - 25}}{\sqrt{x - 5}}
    &{\mathrm{v.})} &\ y = \frac{1}{\sqrt{x + 5}}
    &{\mathrm{vi.})} &\ \vert x \vert = y^{2} + 5
}}\]
    \vskip0.25in
    \hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
          xmax=26,ymax=7,
          axis lines=middle,
          restrict y to domain=-3:6.5,
          enlargelimits={abs=1cm},
          axis line style={latex-latex},
          ticklabel style={fill=white},
          ytick=\empty,
          xtick={-5,5}
]
\addplot[domain=5:26,mark=none,samples=201] {sqrt(x + 5)};
\addplot[domain=-6:5,dashed,thin,mark=none,samples=201] {sqrt(x + 5)};

\draw [densely dashed] (5,3.16227766) -- (5,0);
\draw [fill=white] (5,3.16227766) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}
\hspace{\fill}
\vskip0.25in

\noindent {\bf 2.)} Which of the following products is equal to an integral power of 10?
\[ \makebox[\textwidth][l]{\kern4em\alignShortstack{
\llap{i.)} &\ 1
&{\mathrm{ii.})} &\ 5^{-3}\left(\frac{1}{8}\right)
&{\mathrm{iii.})} &\ 5^{-3}\left(\frac{1}{80}\right)
&{\mathrm{iv.})} &\ 5^{-3}\left(\frac{1}{800}\right) \\
\llap{v.)} &\ \left(\frac{4}{9}\right)^{3}15^{6}
&{\mathrm{vi.})} &\ 2^{-6}25^{-3}
&{\mathrm{vii.})} &\ \left(\frac{1}{2}\right)^{6}\left(\frac{1}{25}\right)^{3}
&{\mathrm{viii.})} &\ \left(\frac{7}{4}\right)^{6}\left(\frac{1}{5^{4}49}\right)^{3}
}}\]
\vskip0.25in
\end{document}

In the image below, a red line has been added at 4em indent to show the alignment of column 1 right parens across different problems, which was the OP's request.

enter image description here


ADDENDUM:

The following essentially does the same as above, but simplifies the input for adding the answer labels, with the \LBL{integer} macro.

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
%\pgfplotsset{compat=1.11}
\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in} \setlength{\textwidth}{6.1in}
\setlength{\topmargin}{0.0in} \setlength{\textheight}{9in}

\usepackage{tabstackengine}
\stackMath
\setstackgap{S}{10pt}
\setstackaligngap{5em}
\makeatletter
\renewcommand\TAB@delim[1]{\displaystyle#1}%
\makeatother
\newcommand\LBL[1]{\llap{\romannumeral#1.)}}
\begin{document}
\noindent {\bfseries 1.)} Which of the following functions is graphed?
\[ \makebox[\textwidth][l]{\kern4em\alignShortstack{
     \LBL{1} &\ y = (x + 5)^{2}
    &\LBL{2} &\ y = \sqrt{x + 5}
    &\LBL{3} &\ x = y^{2} + 5
    \\
     \LBL{4} &\ y = \frac{\sqrt{x^{2} - 25}}{\sqrt{x - 5}}
    &\LBL{5} &\ y = \frac{1}{\sqrt{x + 5}}
    &\LBL{6} &\ \vert x \vert = y^{2} + 5
}}\]
    \vskip0.25in
    \hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
          xmax=26,ymax=7,
          axis lines=middle,
          restrict y to domain=-3:6.5,
          enlargelimits={abs=1cm},
          axis line style={latex-latex},
          ticklabel style={fill=white},
          ytick=\empty,
          xtick={-5,5}
]
\addplot[domain=5:26,mark=none,samples=201] {sqrt(x + 5)};
\addplot[domain=-6:5,dashed,thin,mark=none,samples=201] {sqrt(x + 5)};

\draw [densely dashed] (5,3.16227766) -- (5,0);
\draw [fill=white] (5,3.16227766) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}
\hspace{\fill}
\vskip0.25in

\noindent {\bfseries 2.)} Which of the following products is equal to an integral power of 10?
\[ \makebox[\textwidth][l]{\kern4em\alignShortstack{
 \LBL{1} &\ 1
&\LBL{2} &\ 5^{-3}\left(\frac{1}{8}\right)
&\LBL{3} &\ 5^{-3}\left(\frac{1}{80}\right)
&\LBL{4} &\ 5^{-3}\left(\frac{1}{800}\right)
\\
 \LBL{5} &\ \left(\frac{4}{9}\right)^{3}15^{6}
&\LBL{6} &\ 2^{-6}25^{-3}
&\LBL{7} &\ \left(\frac{1}{2}\right)^{6}\left(\frac{1}{25}\right)^{3}
&\LBL{8} &\ \left(\frac{7}{4}\right)^{6}\left(\frac{1}{5^{4}49}\right)^{3}
}}\]
\vskip0.25in
\end{document}

You must log in to answer this question.

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