26

I want to describe the variables involved in an equation in an itemized environment such that every item begins with the variable name and subsequently comes the description for it. I'd like to have all the descriptions left aligned.

Here is a MWE that of course does not produce what I am looking for.

\documentclass{standalone}
\begin{document}
$E[g(x)] = \int_{-\infty}^{+\infty} f_X(x) \, g(x) \, \mathrm{d}x$.
%
where,
%
\begin{itemize}
    \item $x$      \quad is a continuous random variable.
    \item $f_X(x)$ \quad is the PDF of $x$.
    \item $g(x)$   \quad is a function of $x$.
\end{itemize}
\end{document}
  • usepackage{enumitem} and \begin{itemize}[align=left] and then \item[$x$]{is a continuous random variable.}? – Adam Liter Nov 30 '13 at 8:59
  • @Adam, That doesn't seem to work right for me. Did you try and it worked? – Ali Nov 30 '13 at 9:05
  • Ah, sorry. I think I understand what you want now. Do you still want the bullet points to be there? – Adam Liter Nov 30 '13 at 9:11
  • No worries. Yes, I do want the bullets as well =) – Ali Nov 30 '13 at 9:21
35

What about this

\documentclass{article}
\begin{document}
$E[g(x)] = \int_{-\infty}^{+\infty} f_X(x) \, g(x) \, \mathrm{d}x$.
%
where,
%
\begin{itemize}
    \item{\makebox[2cm]{$x$\hfill} is a continuous random variable.}
    \item{\makebox[2cm]{$f_X(x)$\hfill} is the PDF of $x$.}
    \item{\makebox[2cm]{$g(x)$\hfill} is a function of $x$.}
\end{itemize}
\end{document} 

Output

enter image description here

You can avoid using \hfill for each item if you specify the second optional argument of \makebox to be the letter l (for left):

\documentclass{article}
\begin{document}
$E[g(x)] = \int_{-\infty}^{+\infty} f_X(x) \, g(x) \, \mathrm{d}x$.
%
where,
%
\begin{itemize}
    \item{\makebox[2cm][l]{$x$} is a continuous random variable.}
    \item{\makebox[2cm][l]{$f_X(x)$} is the PDF of $x$.}
    \item{\makebox[2cm][l]{$g(x)$} is a function of $x$.}
\end{itemize}
\end{document} 
  • 3
    I think this \makebox is an excellent solution as it will work for lists that go onto the next page. – Steven C. Howell Nov 23 '15 at 17:44
  • @karlkoeller \makebox[2cm][1] doesn't work in beamer. – alhelal Feb 25 '18 at 7:08
13

Using a tabular as in @PrzemysławScherwentke's answer is a good way to go.

If you still wish to use itemize, here are two options, one without bullets and one with bullets.

\documentclass{article}

\begin{document}
$E[g(x)] = \int_{-\infty}^{+\infty} f_X(x) \, g(x) \, \mathrm{d}x$.
%
where,

% Without bullets
\begin{itemize}
    \item[$x$]{is a continuous random variable.}
    \item[$f_X(x)$]{is the PDF of $x$.}
    \item[$g(x)$]{is a function of $x$.}
\end{itemize}

% With bullets
\begin{itemize}
    \item{$x$\hphantom{$g(x)f_X(x)$} is a continuous random variable.}
    \item{$f_X(x)$\hphantom{$xg(x)$} is the PDF of $x$.}
    \item{$g(x)$\hphantom{$xf_X(x)$} is a function of $x$.}
\end{itemize}

\end{document}

enter image description here

The answer without bullets makes use of the optional argument of \item, which just gives the list item a label. The answer with bullets makes use of \hphantom{} to ensure that the amount of horizontal space taken up in each line is the same as in the other lines.

  • This seems like a great option as it will work for list that span over a page. – Steven C. Howell Nov 23 '15 at 17:42
11

I hope that itemize is only a suggestion. A simple solution without it.

\documentclass{article}
\begin{document}
$E[g(x)] = \int_{-\infty}^{+\infty} f_X(x) \, g(x) \, \mathrm{d}x$.
%
where

\begin{tabular}{@{$\bullet$ }ll}
   $x$      & is a continuous random variable.\\
   $f_X(x)$ & is the PDF of $x$.\\
   $g(x)$   & is a function of $x$.
\end{tabular}
\end{document}

enter image description here

  • Thanks, Przemysław. Actually, I am using this within the beamer class. I have a lot of macros customizing my lists. So, I'd rather have it defined in the itemize environment. – Ali Nov 30 '13 at 9:21
  • One can also use \labelitem instead of directly putting \bullet. – koppor Jul 10 '16 at 14:49
6

To emphasize the connection between the main formula and the three explanatory lines, I'd place them all in an align* environment. No real need to clutter up the picture with text bullets.

enter image description here

\documentclass{article}
\usepackage{mathtools}
\DeclareMathOperator{\E}{E} % define the expectation operator symbol
\begin{document}
\begin{align*}
\E[g(x)] &= \int_{-\infty}^{+\infty} f_X(x) g(x) \, \mathrm{d}x\\
\shortintertext{where}
x      &\ \text{is a continuous random variable,}\\
f_X(x) &\ \text{is the pdf of $x$, and}\\
g(x)   &\ \text{is a function of $x$.}
\end{align*}
\end{document}

If more space is desired between the variables and the explanatory text, one could replace &\ with &\quad.


Second proposed solution, incorporating information that this is part of a beamer document:

enter image description here

\documentclass{beamer}
\usepackage{amsmath}
\DeclareMathOperator{\E}{E}
\begin{document}
\begin{frame}
$\begin{array}{l@{}l}
\E[g(x)]&{}= \int_{-\infty}^{+\infty} f_X(x) g(x)\, \textnormal{d}x, \text{ where}\\[0.75ex]
x      &\text{is a continuous random variable,}\\
f_X(x) &\text{is the pdf of $x$, and}\\
g(x)   &\text{is a function of $x$.}
\end{array}$
\end{frame}
\end{document}

Observe that because the main text font is not a "roman"/serif font, it's better to use \mathnormal than \mathrm to set the "differential operator" symbol d in upright shape.

  • Thanks, Mico. I am explaining this in a beamer frame and that is why I want it itemized. – Ali Nov 30 '13 at 9:27
  • @Ali - I've provided a second solution, which incorporates the information that you're preparing a beamer presentation. I still don't think it's necessary to provide "bullet points". – Mico Nov 30 '13 at 9:52

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.