5

In Overleaf, I would like to show variable names with their equation behind them.

To do so, I have tried:

\begin{align}
      Entropy \quad  1 + \frac{\sum_{j=1}^{N} p_{ij}log_{2}(p_{ij})}{log_{2}n}\\
      IDF \quad  log_{2} \frac{n}{\sum_{j=1}^{N}b(tf_{ij})}
      \\
      Normal\quad \frac{1}{\sqrt{\sum_{j=1}^{N} tf_{ij}^{2}}}
      \\
      ProbIDF \quad log_{2} \frac{n - \sum_{j=1}^{N} b(tf_{ij})}{\sum_{j=1}^{N} b(tf_{ij})}
      \end{align}

Which leads to:

enter image description here

And, I have tried:

\begin{itemize}
      \item Entropy \quad \quad \(1 + \frac{\sum_{j=1}^{N} p_{ij}log_{2}(p_{ij})}{log_{2}n}\)
      \\
      \item IDF \quad \quad \(log_{2} \frac{n}{\sum_{j=1}^{N}b(tf_{ij})}\)
      \\
      \item Normal \quad \quad \(\frac{1}{\sqrt{\sum_{j=1}^{N} tf_{ij}^{2}}}\)
      \\
      \item ProbIDF \quad \quad \(log_{2} \frac{n - \sum_{j=1}^{N} b(tf_{ij})}{\sum_{j=1}^{N} b(tf_{ij})}\)\\
  \end{itemize}

Which leads to:

enter image description here

In the latter case, the words are aligned vertically, but the equations are not. How can I vertically align both?

0

2 Answers 2

11

Some ideas:

\documentclass{article}

\usepackage{geometry}% more generous margins
\usepackage{lipsum}% dummy text
\usepackage{amsmath}

\begin{document}

\lipsum*[66]
\begin{align}
&\text{Entropy} && 1 + \frac{\sum_{j=1}^{N} p_{ij}\log_{2}(p_{ij})}{\log_{2}n}\\
&\text{IDF}     && \log_{2} \frac{n}{\sum_{j=1}^{N}b(tf_{ij})}\\
&\text{Normal}  && \frac{1}{\sqrt{\sum_{j=1}^{N} tf_{ij}^{2}}}\\
&\text{ProbIDF} && \log_{2} \frac{n - \sum_{j=1}^{N} b(tf_{ij})}{\sum_{j=1}^{N} b(tf_{ij})}
\end{align}
\lipsum*[66]
\[
\begin{aligned}
&\text{Entropy} && 1 + \frac{\sum_{j=1}^{N} p_{ij}\log_{2}(p_{ij})}{\log_{2}n}\\
&\text{IDF}     && \log_{2} \frac{n}{\sum_{j=1}^{N}b(tf_{ij})}\\
&\text{Normal}  && \frac{1}{\sqrt{\sum_{j=1}^{N} tf_{ij}^{2}}}\\
&\text{ProbIDF} && \log_{2} \frac{n - \sum_{j=1}^{N} b(tf_{ij})}{\sum_{j=1}^{N} b(tf_{ij})}
\end{aligned}
\]
\lipsum*[66]
\begin{itemize}
\item \makebox[5em][l]{Entropy} $\displaystyle 1 + \frac{\sum_{j=1}^{N} p_{ij}\log_{2}(p_{ij})}{\log_{2}n}$
\item \makebox[5em][l]{IDF} $\displaystyle \log_{2} \frac{n}{\sum_{j=1}^{N}b(tf_{ij})}$
\item \makebox[5em][l]{Normal} $\displaystyle \frac{1}{\sqrt{\sum_{j=1}^{N} tf_{ij}^{2}}}$
\item \makebox[5em][l]{ProbIDF} $\displaystyle \log_{2} \frac{n - \sum_{j=1}^{N} b(tf_{ij})}{\sum_{j=1}^{N} b(tf_{ij})}$
\end{itemize}

\end{document}

enter image description here

Random notes:

  • the logarithm is a math operator, so use \log, not log
  • words like "Entropy" are text, and you should type them as such
2

You can use an invisble alignment using a & at the beginning of each line:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
    \begin{align}
     &  Entropy &  1 + \frac{\sum_{j=1}^{N} p_{ij}log_{2}(p_{ij})}{log_{2}n}\\
     &  IDF  &  log_{2} \frac{n}{\sum_{j=1}^{N}b(tf_{ij})}\\
     &  Normal & \frac{1}{\sqrt{\sum_{j=1}^{N} tf_{ij}^{2}}}\\
     &  ProbIDF  & log_{2} \frac{n - \sum_{j=1}^{N} b(tf_{ij})}{\sum_{j=1}^{N} b(tf_{ij})}
    \end{align}
\end{document}

enter image description here

EDIT: Or if you want the equations to be left-aligned:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
    \begin{align}
     &  Entropy & & 1 + \frac{\sum_{j=1}^{N} p_{ij}log_{2}(p_{ij})}{log_{2}n}\\
     &  IDF  & & log_{2} \frac{n}{\sum_{j=1}^{N}b(tf_{ij})}\\
     &  Normal & &\frac{1}{\sqrt{\sum_{j=1}^{N} tf_{ij}^{2}}}\\
     &  ProbIDF  & &log_{2} \frac{n - \sum_{j=1}^{N} b(tf_{ij})}{\sum_{j=1}^{N} b(tf_{ij})}
    \end{align}
\end{document}

(Note the second & after the name)

enter image description here

3
  • 1
    I took the liberty of fixing the syntax highlighting.
    – campa
    Commented Aug 11, 2021 at 17:22
  • The names should probably be inside something like \text{}, or \textit{} if you want italics, so that the kerning is correct. Compare $Normal$ and $\textit{Normal}$, the former has a larger space between the N and the o.
    – Willoughby
    Commented Aug 11, 2021 at 17:25
  • @Willoughby I agree, but I'd refer you to the superior answer by user campa.
    – Markus G.
    Commented Aug 11, 2021 at 17:28

You must log in to answer this question.

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