2

I am very new to Latex and trying to document a long list of mathematical transformations. I would like to indent certain formula, so that the whole thing looks like one would do as a DO/FOR-loop in coding.

In Word I would define a set of tabulators and indent the formula then. But I can't get it to work within Latex. The outcome should look like this:

   Formula 1
        Formula 2
    <=> Modified Formula 2, maybe a text comment
<=> Modified Formula 1
        Formula 3
           Formula 4
           Formula 5
    <=> Modified Formula 3

I tried the following code:

%&latex
\documentclass[12pt,fleqn]{scrreprt}
\usepackage[latin1]{inputenc}
\usepackage[german]{babel}
\usepackage{amsmath}
\usepackage{nccmath} 

\usepackage{tabto}
\TabPositions{1.0cm, 3.0cm, 5.0cm, 7.0cm}

\newcommand\tapp[1][1cm]{\hspace*{#1}}

\begin{document}

%  Normal Text can be indented.
\tab 1.Tab\tab 2.Tab \tab 3.Tab \tab 4. Tab

%  Formula can not be indented.

\begin{equation}
\tab \tab h_1 + \frac {c_1^2}{2} = h_{2s} + \frac {c_{2s}^2}{2}
\end{equation}

%  Same exercise using selfdefined "tapp". Gives relative space.

A \tapp b c d

Alpha \tapp b c d

%  Try with "tabto". That doesn't work within equations.

\begin{equation}
   \tabto{3.5cm}   h_1 + \frac {c_1^2}{2} = h_{2s} + \frac {c_{2s}^2}{2}
\end{equation}

\begin{equation}
\tabto{0.5cm} \Leftrightarrow
\tabto{3.4cm} c_{2s}^2 = 2 \cdot (h_1 - h_{2s}) + c_1^2
\end{equation}

\begin{equation} 
   h_1 - h_{2s} = -w_{t,12s}
   \text{ ,Some text added behind formula as a comment}
\end{equation}

\begin{equation} 
\Leftrightarrow
   h_1 - h_{2s} =  -\frac{\kappa R T }{\kappa - 1}
   \left[ \left( \frac{p_2}{p_1} \right) ^ \frac{\kappa-1}{\kappa} - 1 \right]
\end{equation}

\end{document}

I hope someone has a feasible idea.

%%

I am not sure if it is correct to put the next text in here. I used your code to get

%
\documentclass[fleqn]{scrreprt}
\usepackage{amsmath} % for "align*2 and "aligned" environments
\usepackage{showframe}

\begin{document}

\begin{align*}
&\ h_1 + \frac {c_1^2}{2} = h_{2s} + \frac {c_{2s}^2}{2} \\
\Leftrightarrow{} 
&\ c_{2s}^2 = 2 \cdot (h_1 - h_{2s}) + c_1^2 \\
&\quad
   \begin{aligned}
   &\ h_1 - h_{2s} = -w_{t,12s} \\
   \Leftrightarrow{} 
   &\ h_1 - h_{2s} = \frac{\kappa R T }{\kappa - 1}
      \left[ \left( \frac{p_2}{p_1} \right) ^ 
      \frac{\kappa-1}{\kappa} - 1 \right]\\
   \end{aligned} \\
\Leftrightarrow{}
&\ c_{2s}^2 = 2 \cdot \frac{\kappa}{\kappa - 1} 
   p_1 v_1 \left[ \left( \frac{p_2}{p_1} \right) ^
   \frac{\kappa-1}{\kappa} - 1 \right] + c_1^2\\
&\quad
   \begin{aligned}
   &\ c_1 = 0 \text{ , assumption: } c_1 <<c_{2s} \\ 
   \end{aligned}
\end{align*}

\end{document}

The c_1 in the last row should be aligned to the h_1 in the 3 one.

As one can see the code becomes pretty confusing right now already. Since this will go on for a while it would be interesting, if there is a different solution.

1
  • Another approach is to use $\displaystyle ...$ (single line) with some list. For multiple line formulas one could use \begin{minipage}{\linewidth}\begin{equation} ... \end{equation}\end{minipage}. Dec 14 '17 at 22:20
1

Tabbing is a text-mode operation. For displayed equations, I would like to suggest you use aligned environments nested in an align* environment.

If \qquad produces too much indentation for your taste, consider using \quad instead.

enter image description here

\documentclass{scrreprt}
\usepackage{amsmath} 
\begin{document}
\begin{align*}
&\text{Formula 1}\\
&\qquad
   \begin{aligned}
   &\text{Formula 2} \\
   \Leftrightarrow{} 
   &\text{Modified Formula 2}
   \end{aligned} \\
\Leftrightarrow{}
&\text{Modified Formula 1}\\
&\qquad 
   \begin{aligned}
   &\text{Formula 3}\\
   &\qquad
      \begin{aligned}
      &\text{Formula 4} \\
      &\text{Formula 5} 
      \end{aligned} \\
   \Leftrightarrow{}
   &\text{Modified Formula 3}
   \end{aligned}
\end{align*}
\end{document}

Addendum to address the OP's follow-up comment: The second ("real"?) formula you've posted is very different, in struccture, from the first. I'd use the following code to typeset it. Observe that the new solution uses aligned[t] environments instead of aligned environments inside an align* environment and that all \quad and \qquad statements are gone.

enter image description here

\documentclass[fleqn]{scrreprt}
\usepackage{amsmath,amssymb} % "amssymb" for "\ll" macro
\begin{document}

\begin{align*}
&h_1 + \frac {c_1^2}{2} = h_{2s} + \frac {c_{2s}^2}{2} \\
\Leftrightarrow{}
&c_{2s}^2 
  \begin{aligned}[t]
  ={} &2  (h_1 - h_{2s}) + c_1^2 \\
      &h_1 - h_{2s} = -w_{t,12s} \\
  \Leftrightarrow{}
      &h_1 - h_{2s} = \frac{\kappa R T }{\kappa - 1}
          \biggl[ \biggl( \frac{p_2}{p_1} \biggr) ^
          {\!\!(\kappa-1)/\kappa} \!- 1 \biggr]
   \end{aligned} \\
\Leftrightarrow{}
&c_{2s}^2 
  \begin{aligned}[t]
  ={} &2  \frac{\kappa}{\kappa - 1}
   p_1 v_1 \biggl[ \biggl( \frac{p_2}{p_1} \biggr) ^
          {\!\!(\kappa-1)/\kappa} \!- 1 \biggr] + c_1^2\\
   &c_1 = 0 \text{ ; assumption: $c_1 \ll c_{2s}$} 
   \end{aligned}
\end{align*}

\end{document}
5
  • 1
    Insert the instruction \allowdisplaybreaks if it's necessary to allow page breaks inside the align* environment.
    – Mico
    Dec 14 '17 at 10:09
  • I introduced my formula into your code and have this now
    – Holger_H
    Dec 14 '17 at 12:13
  • @Holger_H - I've edited my answer with an addendum that addresses your modified formatting needs.
    – Mico
    Dec 14 '17 at 13:18
  • Thank you very much for your support. The layout is now exactly what it should look like. I think you agree, that this is super difficult to track. Do you think there is a differnt solution with simple "tabbing"?
    – Holger_H
    Dec 14 '17 at 15:08
  • @Holger_H - As I wrote before, "tabbing" (in LaTeX) is a text-mode-only operation. I fully agree with you that the layout you've come up with requires some rather complex programming for its implementation in LaTeX. I have to tell you though that, IMNSHO, your preferred layout is both complex and not exactly easy to grasp. You may want to take this opportunity to rethink (a) what it is you're trying to achieve and (b) decide if your objective can be achieved using a simpler, less convoluted layout.
    – Mico
    Dec 14 '17 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.