# Aligning sets of equations with alignat and multicol

I am wondering if there is a relatively easy and straightforward way to get my equals signs under "Derivates" and "Integrals" to align, and to have the d/dx and integrals signs aligned as well.

\documentclass{article}
\usepackage{multicol,amsmath,physics}

\begin{document}

\section*{Integrals}
\begin{multicols}{2}
\noindent
\begin{alignat*}{2}
&\int k \dd{x}&&=kx+c\\
&\int x^n \dd{x}&&=\frac{1}{n+1} x^{n+1}+c
\end{alignat*}
\columnbreak
\begin{alignat*}{2}
&\int k f(x) \dd{x} &&= k \int f(x) \dd{x}\\
&\int \frac{1}{x} \dd{x}&&=\ln |x| + c
\end{alignat*}
\end{multicols}

\section*{Derivatives}
\begin{multicols}{2}
\noindent
\begin{alignat*}{2}
&\dv{x}c&& = 0\\
&\dv{x} \sqrt{x}&&=\frac{1}{2\sqrt{x}}
\end{alignat*}
\columnbreak
\begin{alignat*}{2}
&\dv{x} x^n&&=nx^{n-1}
\end{alignat*}
\end{multicols}
\end{document}


I found many strange double &s in your code. I think those cause the misalignments.

What I propose is this:

• Since the equations are grouped, use another name for the section.

• Use the amsmath package text macro to insert the text (e.g. the "Integrals" and "Derivative" parts)

• Adjust the right side with && where the text is missing, i.e. you fool the alignat environment by telling it to align to nothing

• (Possibly) revise any spacings or issues

Here is the code:

\documentclass{article}
\usepackage{multicol,amsmath,physics}

\begin{document}

\section*{Equations}
\begin{multicols}{2}
\noindent
\begin{alignat*}{2}
\text{\textbf{Integrals}}&\\
\int k \dd{x}&=kx+c\\
\int x^n \dd{x}&=\frac{1}{n+1} x^{n+1}+c\\
\text{\textbf{Derivatives}}&\\
\dv{x}c& = 0\\
\dv{x} \sqrt{x}&=\frac{1}{2\sqrt{x}}
\end{alignat*}
\columnbreak
\begin{alignat*}{2}
&&\\
\int k f(x) \dd{x} &= k \int f(x) \dd{x}\\
\int \frac{1}{x} \dd{x}&=\ln |x| + c\\
&&\\
\dv{x} x^n&=nx^{n-1}
\end{alignat*}
\end{multicols}
\end{document}


You need no multicol. I present three ways for your table of integrals and one for the derivatives: I believe that the names are explicit about my preference.

Sorry, but I don't consider the physics package among my favorite, so I provided alternative commands.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\dd}{\mathop{}\!\mathrm{d}}
\newcommand{\dv}[1]{\frac{\mathrm{d}}{\mathrm{d}#1}}
\newcommand{\sep}{\hspace{6em}}

\begin{document}

\section*{Integrals}
Here is an ugly table of elementary antiderivatives
\begin{alignat*}{6}
&\int k   &&\dd{x} &&= kx+c                    &\sep &\int k f(x)      &&\dd{x} &&= k \int f(x) \dd{x} \\
&\int x^n &&\dd{x} &&= \frac{1}{n+1} x^{n+1}+c &     &\int \frac{1}{x} &&\dd{x} &&= \ln |x| + c
\end{alignat*}
Here is a bad table of elementary antiderivatives
\begin{align*}
\int k   \dd{x} &= kx+c                    & \int k f(x)      \dd{x} &= k \int f(x) \dd{x} \\
\int x^n \dd{x} &= \frac{1}{n+1} x^{n+1}+c & \int \frac{1}{x} \dd{x} &= \ln |x| + c
\end{align*}
Here is a good table of elementary antiderivatives
\begin{align*}
&\int k   \dd{x} = kx+c                    && \int k f(x)      \dd{x} = k \int f(x) \dd{x} \\
&\int x^n \dd{x} = \frac{1}{n+1} x^{n+1}+c && \int \frac{1}{x} \dd{x} = \ln |x| + c
\end{align*}

\section*{Derivatives}
Here is a table of elementary derivatives
\begin{align*}
\dv{x}c         &= 0 & \dv{x} x^n &= nx^{n-1} \\
\dv{x} \sqrt{x} &= \frac{1}{2\sqrt{x}}
\end{align*}

\end{document}


I don't think this is a nice alignment. Anyway, you can have this alignment without multicols. I also suggest simpler alignments, either on the = signs, or on the beginning of the formulae. In the last group, I also show the possibility to align the ds in the numerator and denominator of the derivatives:

\documentclass{article}
\usepackage{multicol,amsmath,physics}

\begin{document}

\section*{Integrals}
\begin{alignat*}{4}
&\int k \dd{x}&&=kx+c & \hspace{4em}
&\int k f(x) \dd{x} &&= k \int f(x) \dd{x}\\
&\int x^n \dd{x}&&=\frac{1}{n+1} x^{n+1}+c & &\int \frac{1}{x} \dd{x}&&=\ln |x| + c
\end{alignat*}

\section*{Derivatives}
\begin{alignat*}{4}
&\dv{x}c&& = 0 & \hspace{8em}&\dv{x} x^n&&=nx^{n-1}\\
&\dv{x} \sqrt{x}&&=\frac{1}{2\sqrt{x}}
\end{alignat*}

\section*{Integrals}
\begin{alignat*}{2}
&\int k \dd{x}=kx+c & \hspace{4em}
&\int k f(x) \dd{x} = k \int f(x) \dd{x}\\
&\int x^n \dd{x}=\frac{1}{n+1} x^{n+1}+c & &\int \frac{1}{x} \dd{x}=\ln |x| + c
\end{alignat*}

\section*{Derivatives}
\begin{alignat*}{2}
&\dv{x}c = 0 & \hspace{8em}\dv{x} x^n&=nx^{n-1}\\
&\dv{x} \sqrt{x}=\frac{1}{2\sqrt{x}}
\end{alignat*}

\section*{Integrals}
\begin{alignat*}{2}
\int k \dd{x}&=kx+c & \hspace{4em}
\int k f(x) \dd{x} &= k \int f(x) \dd{x}\\
\int x^n \dd{x}&=\frac{1}{n+1} x^{n+1}+c &\int \frac{1}{x} \dd{x}&=\ln |x| + c
\end{alignat*}

\section*{Derivatives}
\begin{alignat*}{2}
&\dv{\phantom{x}}{x}\,c = 0 & \hspace{8em}\dv{\phantom{x}}{x}\, x^n&=nx^{n-1}\\
&\dv{\phantom{x}}{x} \sqrt{x}=\frac{1}{2\sqrt{x}}
\end{alignat*}

\end{document}