# How do I make this long equation look neat?

Anybody knows how to make this long equation look neat in LaTeX? Many thanks!

\documentclass[12pt]{article}

\begin{document}
$$t_p= \left\{ \begin{array}{ll} 1 & D=0 \\ 1-(Credit_{fed}^L+Credit_{provin}^L) & 0<D\leq 200 \\ 200*[1-(Credit_{fed}^L+Credit_{provin}^L)] +(D-200)*[1-(Credit_{fed}^H+Credit_{provin}^H)] & D>200 \end{array} \right.$$
\end{document}

• Welcome to Maths SX! Could you post a full compilable code, as a starting point? Nov 29, 2017 at 0:05
• Start by using “C” instead of “Credit”. Nov 29, 2017 at 0:07
• You should edit your question and insert this code therein. B.t.w. what are your document class, paper format, font size, &c.? Nov 29, 2017 at 0:20
• \documentclass[12pt]{article} Nov 29, 2017 at 0:23

If you want the variable names Credit, fed and provin to be in italics, use \mathit{Credit}, etc. Or \mathrm{Credit} for Roman.

Since you have a complicated repeated expression, I suggest you define a function C(K) to simplify your definition of t_p. I use the cases environment from the amsmath package.

Here is the code:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
Let $C(K)=\mathit{Credit}_{\mathit{fed}}^K+\mathit{Credit}_{\mathit{provin}}^K$. Then
$$t_p=\begin{cases} 1 & D=0 \\ 1-C(L) & 0<D\leq 200 \\ 200\big(1-C(L)\big)+(D-200)\big(1-C(H)\big) & D>200 \end{cases}$$
\end{document}

• It may seem strange, but we typically do not use comments for offering thanks. The way to show appreciation is by up-voting the answer or answers that you think are helpful. An answer that you feel best addresses your question should be "accepted". More information can be found here. Dec 4, 2017 at 15:30

Something like this?

Observe the use of "roman", i.e., upright, lettering for the variable names 'Credit', 'fed', and 'provin'.

\documentclass[12pt]{article}
\newcommand\vn[1]{\mathrm{#1}} % "variable name"
\usepackage{mathtools} % for "dcases" environment
\begin{document}

$$t_p= \begin{dcases} 1 & D=0 \\[1ex] 1-(\vn{Credit}_{\vn{fed}}^L+\vn{Credit}_{\vn{provin}}^L) & 0<D\leq 200 \\[1ex] \begin{array}[b]{@{}r@{}} 200\phantom{)}[1-(\vn{Credit}_{\vn{fed}}^L+\vn{Credit}_{\vn{provin}}^L)]\\[1ex] {}+(D-200)[1-(\vn{Credi‌​t}_{\vn{fed}}^H+\vn{Credit}_{\vn{pr‌ovin}}^H)] \end{array} & D>200 \end{dcases}$$
\end{document}


I propose this non-standard layout, with some shortcuts, based o, the empheq package and the alignedat environment:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{empheq}
\newcommand{\credit}{\mathrm{Credit}}
\newcommand{\fed}{\mathrm{fed}}
\newcommand{\provin}{\mathrm{provin}}

\begin{document}

\begin{empheq}[left = {t_p = \empheqlbrace}]{equation}
\begin{alignedat}{4}
& 1 &\hspace{1.5em}\text{if }&D=0, &\hspace{4em} &
1-\bigl(\mathrm{Credit}_\mathrm{fed}^L + \mathrm{Credit}_\mathrm{provin}^L\bigr) &\qquad\text{if } & 0 <D\leq 200, \\[1.5ex] %
& \mathrlap{\begin{aligned}[b] 200*\bigl[1&-\bigl(\credit_{\fed} ^L + \credit_{\provin}^L\bigr)\bigr] \\& + (D-200)*[1-\bigl(\credit_{\fed}^H + \credit_{\provin}^H\bigl)\bigr]\end{aligned}} & & & & & \quad\text{if } & D>200.
\end{alignedat}
\end{empheq}

\end{document}


Suggestion: use substitution and definition.

E.g. the two terms with C..L and C..H are structurally identical and only differ by index L and H. Define e.g. S^(x):=C_fed^(x)+C_provin^(x) with X = H or L, in some nice way.

Substitute this term in your 3 cases and it will have a much better look and feel.

• In principle I agree, but on this site we tend to provide concrete answers presenting some working code (and possibly a snapshot of the output). Jul 6, 2021 at 12:09

Referencing answer How do I make this long equation look neat? I'd slightly rearrange it, which hopefully removes some back and forth, i.e. "understand without thinking about it":

Code:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
Let $C(K)=\mathit{Credit}_{\mathit{fed}}^K+ \mathit{Credit}_{\mathit{provin}}^K$. Then
$$t_p=\begin{cases} 1 & D=0 \\ (1-C(L)) & 200 \geq D>0 \\ \big(1-C(L)\big) 200 +(D-200)\big(1-C(H)\big) & D>200 \end{cases}$$
\end{document}


Rational:

• grouping shows progressive changes
• reading direction for the ranges of D are always the same (i.e. larger values to the left in this case)
• get what's relevant without thinking too much about it (so you can focus on more relevant things than just deciphering ;-) )

Remark: the last two terms in braces should be interchanged to follow the same logic ...

BTW: Somebody lost dividing by D in the last case ...