41

I want to write an equation with $\mid$, but it is too small, can i make it bigger in any way?

I am kinda new to TeX so i have no idea how to do it.

5
  • 2
    Perhaps How can you address the size of surrounding parentheses whose size is determined by \left and \right? can help... not sure about the usage of \mid in your case. More detail?
    – Werner
    Commented Oct 31, 2013 at 4:36
  • 2
    Well, \Bigm| would help? And what exactly do you need it for (because there're at least 5 different meanings of |)? Maybe you can help us in helping you by providing a Minimal (non-)Working Example...
    – yo'
    Commented Oct 31, 2013 at 7:37
  • Are you sure that you want \mid (which is usually used to such that meaning) or do you want a vertical bar to denote the absolute value, for example, on a fraction? If you want the second option, use \left|...\right|.
    – Sigur
    Commented Oct 31, 2013 at 10:57
  • I'm not sure to have ever heard of a "given that" symbol. Can you show what it is and a context where it's used?
    – egreg
    Commented Oct 31, 2013 at 15:14
  • @egreg: I took it to mean conditional probability, e.g., P(X = x|Y = y).
    – alexwlchan
    Commented Nov 2, 2013 at 8:59

4 Answers 4

27

2017 Update: Since \mid is a relation, under normal circumstances the spaces manually inserted around \middle| should be thick \; instead of thin \,. See table on p.170 of the TEXbook.


Instead of \mid, you can use \middle command to enlarge vertical delimiter and insert spaces manually, here is an example:

\documentclass{article}

\usepackage{mathtools}

\begin{document}
\[S=\left(\frac{\sum_{i=1}^{n}X_i}{n}\;\middle|\;X_i\sim\chi^2(k)\right)\]
\[\left.\frac{\sum_{i=1}^{n}X_i+Y_i}{n}\;\middle|\;X\sim\chi^2_k\;\middle|\;Y\sim\mathcal{N}(\mu,\sigma^2)\right.\]

\end{document}

Result:

enter image description here

Better yet, we can make a custom command for our conveniences:

\makeatletter
\newcommand{\@giventhatstar}[2]{\left(#1\;\middle|\;#2\right)}
\newcommand{\@giventhatnostar}[3][]{#1(#2\;#1|\;#3#1)}
\newcommand{\giventhat}{\@ifstar\@giventhatstar\@giventhatnostar}
\makeatother

It works sorta like \DeclarePairedDelimiter in mathtools, for example:

\[\giventhat{f(x)=\frac{x^2}{2}}{x=1,2,3,\dotsc}\]
\[\giventhat[\big]{f(x)=\frac{x^2}{2}}{x=1,2,3,\dotsc}\]
\[\giventhat[\Big]{f(x)=\frac{x^2}{2}}{x=1,2,3,\dotsc}\]
\[\giventhat*{f(x)=\frac{x^2}{2}}{x=1,2,3,\dotsc}\]

will give you:

3
  • 2
    \cdots is not the proper dots to use here
    – daleif
    Commented Nov 1, 2013 at 7:30
  • See also my addition
    – daleif
    Commented Nov 1, 2013 at 7:41
  • 1
    Really helpfull, thanks. However, when adding the commands at the beginning of the document I had to make some changes and include the \ensuremath{...} command: \usepackage{mathtools} \makeatletter \newcommand{\@giventhatstar}[2]{\ensuremath{\left({#1}\;\middle|\;{#2}\right)}} \newcommand{\@giventhatnostar}[3][]{#1(#2\;#1|\;#3#1)} \newcommand{\giventhat}{\@ifstar\@giventhatstar\@giventhatnostar} \makeatother Commented Aug 15, 2018 at 11:47
23

Sounds like conditional probability. In that case I usually recommend our students to use something similar to

\newcommand\given[1][]{\:#1\vert\:}

Which will be manually scalled via, say

\given[\Big] 

Then the code makes sense when read


ADDITION. Building further on Francis' suggestion \given can be build into his macros such that the macros only takes one argument.

\documentclass[a4paper]{memoir}
\usepackage{mathtools}
\newcommand\givenbase[1][]{\:#1\lvert\:}
\let\given\givenbase
\newcommand\sgiven{\givenbase[\delimsize]}
\DeclarePairedDelimiterX\Basics[1](){\let\given\sgiven #1}
\newcommand\Average{E\Basics}
\begin{document}
\begin{align*}
  \Basics{X} \qquad \Basics[\Big]{ X \given Y}\\
  \Average{X} \qquad \Average[\Big]{ X \given Y}\\
\end{align*}
\end{document}

enter image description here

2
  • Maybe \operatorname{E} instead of E?
    – Francis
    Commented Nov 1, 2013 at 8:54
  • 2
    It might be yes. Though I think most people think of it in the same manner as f(x), i.e. just a function. Some people use an upright E, some people even use \mathbb{E}. Depends on the tradition.
    – daleif
    Commented Nov 1, 2013 at 9:45
5

This uses features of the scalerel package.

\documentclass{article}
\usepackage{scalerel}
\begin{document}
\noindent You can stretch it to a size:\\
$A \mid 
\mathrel{\stretchto{\mid}{3ex}} 
\mathrel{\stretchto{\mid}{4ex}}
B$\\
or you can stretch it to fit something else:\\
$ \stretchrel{\mid}{\displaystyle\frac{A}{B}} $\\
\end{document}

enter image description here

1

Use \left.\right|

For example $$\mathbb{E}(Y^3) = \left.\frac{d^3 M_Z(t)}{d t^3}\right|_{t=0}$$

enter image description here

You must log in to answer this question.

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