5

How can I write the below format of an equation in latex?

enter image description here

A vertical line beside an equation which specializes amounts of equation's variables.

2
  • Does the vertical bar have to be as thick as what's shown in the screenshot? Or will a more standard width do? Please advise.
    – Mico
    Commented Sep 3, 2018 at 6:37
  • 1
    In paint I draw by default thick line. But the thickness is not important at this step. However I think that thicker lines can be seem more beautiful. Commented Sep 3, 2018 at 6:47

2 Answers 2

8

I would use the \substack directive, which is provided by the amsmath package, for the material below and to the right of the vertical bar. Depending on the desired height of the vertical bar, you may need to employ \Big, \bigg, or \Bigg to size the bar.

enter image description here

A purely personal opinion: I wouldn't make the vertical bar any thicker.

\documentclass{article}
\usepackage{amsmath} % for "\substack" macro
\begin{document}
\[
a=(b+c)\cdot 8 \Bigr|_{\substack{b=6\\c=2}}
 =(b+c)\cdot 8\biggr|_{\substack{b=6\\c=2}}
 =(b+c)\cdot 8\Biggr|_{\substack{b=6\\c=2}}
\]
\end{document} 
2
  • Thanks a bunch. The thickness is not changeable?! Commented Sep 3, 2018 at 7:05
  • 4
    It is changeable, but I really wouldn't do it. Good typography is importantly about balance: All parts of the equation should be roughly equally "visible". If you make the bar any thicker, what most readers will notice first and foremost is the vertical bar -- and probably nothing else.
    – Mico
    Commented Sep 3, 2018 at 7:07
4

An idiomatic way to do this is using left/right:

\documentclass{article}
\usepackage{amsmath} % for "\substack" macro
\begin{document}
\begin{align}
a &= \left. (b+c)\cdot 8 \right|_{\substack{b=6\\c=2}}
  &= \left. (b+c)\cdot 8 \right|_{\substack{b=6\\c=2}}
  &= \left. (b+c)\cdot 8 \right|_{\substack{b=6\\c=2}}
\end{align}
\end{document}

This also has the advantage of resizing to the "contents" of whatever expression you want to annotate.

3
  • Did you mean to insert linebreak directives at the end of the first two rows of the align environment? A separate comment: The \left-\right method produces a rather small vertical bar since the material being encases is just (b+c)\cdot 8. Thus, the claim that this method "has the advantage of resizing to the 'contents' of whatever expression you want to annotate" needs to be taken wih a grain of salt.
    – Mico
    Commented Sep 3, 2018 at 10:50
  • Yes I meant to insert linebreaks. And you're right, but it might be improved if you also left/right the parentheses. But yeah, a larger minimum height wouldn't hurt.
    – rubenvb
    Commented Sep 3, 2018 at 10:56
  • I think a fundamental issue with the OP's setup is that there's no obviously correct "large size" for the vertical bar. That's why I showed 3 separate bars, one for each of three different sizing instructions, viz., \Big, \bigg, and \Bigg. For the case at hand, I don't it's likely that handing off the sizing decision to TeX (via \left and \right) will lead to an aesthetically appealing outcome.
    – Mico
    Commented Sep 3, 2018 at 11:03

You must log in to answer this question.

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