# Align ragged right and ragged left in equation environment

I would like to write a financial calculation that is numbered as an equation. tabular, split and align do not seem to work. tabular delivers an error witin the equation environment.

The result should look like this:

Wood      10,000 €
Steel     25,000 €
Coal       5,000 €
Oil      100,000 €
------------------
Sum      140,000 €


That is, the right “column” is ragged right whereas the left “column” is ragged left.

This code

\documentclass[12pt,a4paper]{report}
\usepackage[british]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[gen]{eurosym}
\begin{document}
$$\begin{split} \text{Wood}\ \ & 10{,}000\ \euro\\ \text{Steel}\ \ & 25{,}000\ \euro\\ \text{Coal}\ \ & 5{,}000\ \euro\\ \text{Oil}\ \ & 100{,}000\ \euro\\ \hline \text{Sum}\ \ & 140{,}000\ \euro \end{split}$$
\end{document}


delivers

.

A workaround, at least for the right “column”, could be to insert \phantom{0} or \phantom{00} in front of the shorter numbers. But the problem regarding the left “column” still remains.

• That's a job for a tabular, rather than split. – egreg Nov 20 '18 at 10:10
• @egreg: Using tabular within the equation environment results in an error. But what I actually need from the equation environment is its numbering. – Nemgathos Nov 20 '18 at 10:12

With tabular:

\documentclass[12pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[gen]{eurosym}

\begin{document}

$$\begin{tabular}{ @{} l r @{} } Wood & 10,000\,\euro\\ Steel & 25,000\,\euro\\ Coal & 5,000\,\euro\\ Oil & 100,000\,\euro\\ \hline Sum & 140,000\,\euro \end{tabular}$$

\end{document}


• Wouldn't a \midrule from booktabs look better than \hline here? – daleif Nov 20 '18 at 10:20
• @daleif Most certainly; but the table should be refactored anyhow. – egreg Nov 20 '18 at 10:22