# Align both names and equations in the same line

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}\\
\\
\\
ProbIDF \quad log_{2} \frac{n - \sum_{j=1}^{N} b(tf_{ij})}{\sum_{j=1}^{N} b(tf_{ij})}
\end{align}


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}


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

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}


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

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}


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)

• I took the liberty of fixing the syntax highlighting. 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. Commented Aug 11, 2021 at 17:25
• @Willoughby I agree, but I'd refer you to the superior answer by user campa. Commented Aug 11, 2021 at 17:28