Skip to content

Instantly share code, notes, and snippets.

@vicapow
Last active November 3, 2024 06:27
Show Gist options
  • Save vicapow/fd736f10b9382e924875f4e093a63d33 to your computer and use it in GitHub Desktop.
Save vicapow/fd736f10b9382e924875f4e093a63d33 to your computer and use it in GitHub Desktop.
% Original question on Reddit: https://www.reddit.com/r/LaTeX/comments/1gi75el/these_commands_arent_working_any_help/
% To view the source code or fork it, see: https://gist.github.com/vicapow/fd736f10b9382e924875f4e093a63d33
% Note, you may need to compile twice to ensure the refernces get updated completely.
\documentclass{article}
\usepackage{amsmath} % Required for split and align environments
\newcommand{\equsl}[2]{
\begin{equation}
% Original:
% \label#1\begin{split}{#2}\end{split}
% Fixed:
\label{#1}\begin{split}{#2}\end{split}
\end{equation}
}
\newcommand{\equl}[2]{
% Original: doesn't show up.
% \begin{equation}\label#1{#2}\end{equation}
% Fixed:
\begin{equation}\label{#1}{#2}\end{equation}
}
\begin{document}
% Example usage of \equl
% This will create a single-line labeled equation.
Here is a single-line equation:
\equl{eq:single_line}{E = mc^2}
% Example usage of \equsl
% This will create a multi-line labeled equation.
Here is a multi-line equation:
\equsl{eq:multi_line}{
f(x) = x^2 + 3x + 2 \\
g(x) = x^3 - 4x + 1
}
% Cross-referencing examples
As shown in Equation~\ref{eq:single_line}, energy is equal to mass times the speed of light squared. And in Equation~\ref{eq:multi_line}, we have a two-part equation with separate definitions for \( f(x) \) and \( g(x) \).
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment