3

I've got the following plain setup:

\usepackage{amsmath, mathtools}
\begin{document}
 \begin{align*}
\begin{array}{c c l}
(f^{-1}(y))' =& \frac{1}{f'(f^{-1}(y))}&\text{\tiny $\vert$ step 1}\\ \\
(f^{-1}(y))'' =& \left(\frac{1}{f'(f^{-1}(y))}\right)'&\text{\tiny $\vert$step 2}\\ \\
(f^{-1}(y))'' =& \frac{-1\cdot(f'(f^{-1}(y)))'}{(f'(f^{-1}(y)))^2}&\text{\tiny $\vert$ step 3}\\ \\
(f^{-1}(y))'' =&\frac{-f''(f^{-1}(y))\,(f^{-1}(y))'}{(f'(f^{-1}(y)))^2}&\text{\tiny $\vert$ step 4}\\\\
(f^{-1}(y))'' =& \frac{-f''(f^{-1}(y))}{(f'(f^{-1}(y)))^3}\\
\end{array} 
\end{align*}
\end{document}

The result looks quite okay, but I wish to have a box around the last line. \Aboxed doesn't do much since it's ripping the structure apart. I've read some solutions with tikz involved, but I'm not familiar with it.

4
  • you should not be using align here as you only have one row and no alignment also array will give incorrect spacing for = and textstyle not displaystyle, but as you are using array you can use \hline to get the horixontal lines and \multicolumn{1}{|c}{...} to get the left vertical and {c|} to get the right vertical. Commented Apr 24, 2021 at 13:58
  • I've adjusted the code
    – Leon
    Commented Apr 24, 2021 at 14:41
  • I'm using array for it's nice centering. But I didn't discovered how to place a box still
    – Leon
    Commented Apr 24, 2021 at 14:43
  • array is intended for matrices and arrays, it uses displaystyle and the spacing around =& is quite wrong for an equation, but if you do use array surround ot with \[..\] not align Commented Apr 24, 2021 at 15:47

3 Answers 3

3

If you really insist on your desired alignment then yes, you might use array, but then there is no reason to use align* outside. The box can be added by the standard LaTeX rule management for tabular/array.

\documentclass{article}

\usepackage{mathtools}
\usepackage{array}

\begin{document}

\[
\setlength{\extrarowheight}{4ex}
\begin{array}{r >{\displaystyle}c l}
(f^{-1}(y))'  ={}& \frac{1}{f'(f^{-1}(y))}                                 &\text{\tiny $\vert$ step 1}\\
(f^{-1}(y))'' ={}& \left(\frac{1}{f'(f^{-1}(y))}\right)'                   &\text{\tiny $\vert$ step 2}\\
(f^{-1}(y))'' ={}& \frac{-1\cdot(f'(f^{-1}(y)))'}{(f'(f^{-1}(y)))^2}       &\text{\tiny $\vert$ step 3}\\
(f^{-1}(y))'' ={}& \frac{-f''(f^{-1}(y))\,(f^{-1}(y))'}{(f'(f^{-1}(y)))^2} &\text{\tiny $\vert$ step 4}\\[3ex]
\cline{1-2}
\multicolumn{1}{|r}{(f^{-1}(y))''=} & \multicolumn{1}{c|}{\dfrac{-f''(f^{-1}(y))}{(f'(f^{-1}(y)))^3}} \\[3ex]
\cline{1-2}
\end{array} 
\]

\end{document}

enter image description here

4

enter image description here

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{align*}
(f^{-1}(y))' &= \frac{1}{f'(f^{-1}(y))}\\ \\
(f^{-1}(y))'' &= \left(\frac{1}{f'(f^{-1}(y))}\right)'\\ \\
(f^{-1}(y))'' &= \frac{-1\cdot(f'(f^{-1}(y)))'}{(f'(f^{-1}(y)))^2}\\ \\
(f^{-1}(y))'' &=\frac{-f''(f^{-1}(y))\,(f^{-1}(y))'}{(f'(f^{-1}(y)))^2}\\\\
\Aboxed{(f^{-1}(y))'' &= \frac{-f''(f^{-1}(y))}{(f'(f^{-1}(y)))^3}}\\
\end{align*}


\end{document}
1
  • Well, I actually want the fractions on the right to be centered. That's why I used array-environment
    – Leon
    Commented Apr 24, 2021 at 14:38
3

With {NiceArray} of nicematrix.

\documentclass{article}
\usepackage{mathtools}
\usepackage{nicematrix}

\begin{document}

\[
\setlength{\extrarowheight}{4ex}
\setlength{\arraycolsep}{0pt}
\begin{NiceArray}{@{\enskip}r>{\displaystyle}c@{\enskip}>{\quad}l}
(f^{-1}(y))'  ={}& \frac{1}{f'(f^{-1}(y))}                                 &\text{\tiny $\vert$ step 1}\\
(f^{-1}(y))'' ={}& \left(\frac{1}{f'(f^{-1}(y))}\right)'                   &\text{\tiny $\vert$ step 2}\\
(f^{-1}(y))'' ={}& \frac{-1\cdot(f'(f^{-1}(y)))'}{(f'(f^{-1}(y)))^2}       &\text{\tiny $\vert$ step 3}\\
(f^{-1}(y))'' ={}& \frac{-f''(f^{-1}(y))\,(f^{-1}(y))'}{(f'(f^{-1}(y)))^2} &\text{\tiny $\vert$ step 4}\\[3ex]
\Block[draw]{1-2}{}%
(f^{-1}(y))''={} & \dfrac{-f''(f^{-1}(y))}{(f'(f^{-1}(y)))^3} \\[3ex]
\end{NiceArray} 
\]

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

You must log in to answer this question.

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