3

I'm pretty new to LaTeX and I'm trying to write properly integrals in my notes.
Here's an example of the code:

\documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\[\int_{-\infty}^{t} f_X(z) \,dz\]
$\int\limits_{-\infty}^{t} f_X(z) \,dz$
\end{document}

The problem is the way the limit is shown in the two versions.

enter image description here versus enter image description here

In summary: I need to put the second limit in an array (as follows) but I would like to display the first version instead of the second one.

\begin{itemize}
    \item se $t < a$, allora
    \[\int_{-\infty}^{t} f_X(z) \,dz = \int_{-\infty}^{t} 0 \cdot \,dz = 0\]
    \item se $a \le x \le b$, allora
    $$
    \begin{array}{rcl}
        \int\limits_{-\infty}^{t} f_X(z) \,dz & = & \int\limits_{-\infty}^{a} 0 \cdot \,dz +
        \int\limits_{a}^{t} \dfrac{1}{b-a} \,dz \\
        & = & \dfrac{z}{b-a}\bigg\rvert_a^t = \dfrac{t-a}{b-a};
    \end{array}
    $$
    \item se $t > b$, allora
    $$
    \begin{array}{rcl}
        \int\limits_{-\infty}^{t} f_X(z) \,dz & = & \int\limits_{-\infty}^{a} 0 \cdot \,dz +
        \int\limits_{a}^{b} \dfrac{1}{b-a} \,dz + \int\limits_{b}^{t} 0 \cdot \,dz\\
        & = & \dfrac{z}{b-a}\bigg\rvert_a^t = 1;
    \end{array}
    $$
\end{itemize}
\end{itemize}

Thanks in advance

7
  • ...not sure... are you looking for \int\nolimits? – Rmano May 7 at 9:20
  • 2
    Also, $$ is not LaTeX: tex.stackexchange.com/questions/503/why-is-preferable-to – Rmano May 7 at 9:21
  • 5
    use \displaystyle at the beginning of your lines where you need to display the limits in your first version, and you can remove the \limits – needle May 7 at 9:21
  • array is the wrong tool here. You want to use a displayed alignment like align*. – campa May 7 at 9:26
  • @Rmano \nolimits was not actually what I was looking for, but thanks for the second hint about why $$ is not LaTeX! – LukeTheWolf May 7 at 10:31
4

You could simply use \displaystyle, but here it is better to use the align* environment. Also instead of doing \,d each time, i recommend you define a macro like for example \def\diff{\,\mathrm{d}}. So each time you what to call it you just do \diff and it will do it for you, and you will make less mistakes that way. Also it is better to use \( or \) to open or close inline math, rather that $

Here is what it would look like using align*

%%% Define before the document %%%%
\def\diff{\,\mathrm{d}}


\begin{document}
    \begin{itemize}
        \item se \(t < a\), allora
            \[\int_{-\infty}^{t} f_X(z) \diff z = \int_{-\infty}^{t} 0 \cdot\diff z = 0\]

        \item se \(a \le x \le b\), allora
        \begin{align*}
            \int_{-\infty}^{t} f_X(z) \diff z  &=  \int_{-\infty}^{a} 0 \cdot \diff z + \int_{a}^{t} \dfrac{1}{b-a} \diff z \\
            &= \dfrac{z}{b-a}\bigg\rvert_a^t \\
            &= \dfrac{t-a}{b-a};
        \end{align*}
        
        \item se \(t > b\), allora
        \begin{align*}
            \int_{-\infty}^{t} f_X(z) \diff z &=  \int_{-\infty}^{a} 0 \cdot \diff z + \int_{a}^{b} \dfrac{1}{b-a} \diff z + \int_{b}^{t} 0 \cdot \,dz \\
            &= \dfrac{z}{b-a}\bigg\rvert_a^t \\
            &= 1;
        \end{align*}
    \end{itemize}
\end{document}

That gives:

enter image description here

2
  • 5
    \newcommand{\diff}{\mathop{}\!d} will only add the thin space when required, for instance, it won't in the case 0\cdot\diff z. Note that the OP doesn't use \mathrm{d} and the answer shouldn't as well. – egreg May 7 at 10:20
  • @egreg to be honest I'm coding LaTeX on VSC, and I used the standard structures offered by the IDE. I thought they were right. So can I ask you which is the proper way to write the diff in LaTeX? Thx in advance – LukeTheWolf May 7 at 10:58
4

I wouldn't place the equations on separate lines below the "se ... allora" conditionals. Separately, I wouldn't insert \cdot before dz.

enter image description here

\documentclass{article} 
\usepackage{amsmath}
\begin{document}
\begin{itemize}
    \item Se $t < a$, allora
    $\displaystyle
      \int_{-\infty}^{t}\! f_X(z) \,dz = \int_{-\infty}^{t} \!0 \,dz = 0$
    \item Se $a \le t \le b$, allora
    $\begin{aligned}[t]
      \int_{-\infty}^{t}\! f_X(z) \,dz &= 
         \int_{-\infty}^{a} \!0 \,dz +
         \int_{a}^{t} \frac{1}{b-a} \,dz \\
         &= \frac{z}{b-a} \bigg\vert_a^t = \frac{t-a}{b-a}
    \end{aligned}$
    \item Se $t > b$, allora
    $\begin{aligned}[t]
      \int_{-\infty}^{t}\! f_X(z) \,dz 
      &= \int_{-\infty}^{a} \!0 \,dz +
         \int_{a}^{b} \frac{1}{b-a} \,dz + 
         \int_{b}^{t} \!0 \,dz\\
      &= \frac{z}{b-a} \bigg\vert_a^b = 1\,.
    \end{aligned}$
\end{itemize}
\end{document}

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.