9

I have a mathematical term produced by two different pieces of code:

\displaystyle H\left(\frac{1}{2},\frac{1}{2}\left|_{C_{k}=1}\right.\right)

enter image description here

\displaystyle H\left(\frac{1}{2},\frac{1}{2}\Big|_{C_{k}=1}\right)

enter image description here

What I was trying to achieve (and that is why I tried many approaches) is produce the vertical line with the same height as the fraction.

As you can see with the first piece of code the line is by far shorter and with the second, although it is better, it is still short.

By trying out the previous approaches I am confused as to why the first approach didn't produce a line of the same height as the \left(,[ etc produces a symbol in the same height as the expression (correct me if I am wrong).

Also my initial concern was how to produced a line with the specifications I mentioned?

5

Your first line of code produces a line with normal height since it surrounds \left|_{C_{k}=1}\right. not he fraction. So you have to use \left.\kern-\nulldelimiterspace\frac{1}{2}\right|. As far, \Big| is concerned the size is not suitable, use \bigg|

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  $\displaystyle H\left(\frac{1}{2},\left.\kern-\nulldelimiterspace\frac{1}{2}\right|_{C_{k}=1}\right)$

  $\displaystyle H\left(\frac{1}{2},\frac{1}{2}\bigg|_{C_{k}=1}\right)$
\end{document}

enter image description here

10

I'd use \bigg and friends; with \left and \right the parentheses turn out to be too big.

\documentclass{article}
\usepackage{mleftright}
\newcommand{\fakeleft}{\mleft.\kern\nulldelimiterspace}
\begin{document}
\[
H\mleft(\fakeleft\frac{1}{2},\frac{1}{2}\mright|_{C_{k}=1}\mright)
\]
\[
H\biggl(\frac{1}{2},\frac{1}{2}\bigg|_{C_{k}=1}\,\biggr)
\]
\end{document}

enter image description here

Unfortunately, \middle wouldn't work in this context, because it's implemented like \left, so it doesn't take a subscript.

7

The following solution simply uses \vrule, which gives exact height and depth of the fraction. (On the other hand, \left...\right doesn't give exact height.) No additional package is needed.

$$
H\left(\frac{1}{2},{\frac{1}{2}\,\vrule\,}_{C_{k}=1}\right)
$$

enter image description here

  • Best and simplest solution so far! I've edited your posting to add a screenshot -- hope you're OK with that. – Mico Dec 18 '14 at 9:30
  • Thank you it is a great solution and I will consider it for future use. Also it is quite elegant. I had to accept the other answer though as it was answering specifically to my question. – Adam Dec 19 '14 at 4:46
  • @Adam Note, that various solutions here differ by the size of the outer brackets. If the inner line is solved (internally) as new internal \left...\right then the outer brackets are greater. – wipet Dec 19 '14 at 7:07
5

just to cover one approach that hasn't yet been mentioned, but is the approach presented in the texbook, wrap \left. ... \right| around the taller portion of the expression:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
H\biggl(\left.\frac{1}{2},\frac{1}{2}\right|_{C_{k}=1}\,\biggr)
\]
\end{document}

output of example code

4

To make the vertical bar extent exactly the height of the fraction (as requested by the OP), the scalerel package can help.

\documentclass{article}
\usepackage{scalerel}
\begin{document}
$\displaystyle H\left(\frac{1}{2},\frac{1}{2}
  {\stretchrel*{\vert}{\frac{1}{2}}}_{C_{k}=1}\right)$
\end{document}

enter image description here

  • Thank you for your answer. This is a useful package indeed. – Adam Dec 19 '14 at 4:49
1

The straightforward way to do this is with \middle, which works just like \left and \right. Unfortunately, the index doesn't get placed correctly. To get placed low enough, I inserted a fake fraction with \vphantom{\frac12}:

\documentclass{article}
\begin{document}
\[
H \left(\frac{1}{2},\frac{1}{2}
  \middle| {\vphantom{\frac12}}_{C_{k}=1}
  \right)
\]
\end{document}

                                                      

A sidenote: This solution is probably "semantically" not really correct, since it is more for things like bra-ket notation where you have a left and a right part (\left\langle \Psi \middle| \xi\right\rangle becomes ⟨ψ|ξ⟩). Your example looks a bit like the "evaluate under this condition" notation (\left. \frac{\partial f}{\partial x} \right|_{x=0}), for example:

                                                                 

In this case, the subscript is a bit lower relative to the vertical line. I guess since your formula is neither of these two standard cases (vertical line splits the bracket vs. vertical line makes a comment on the second fraction), you get to choose your own typography, so I'd just choose what looks good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.