Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to locate my text in such way. At first, I have some formula. There must be a little indent.

$bla-bla-bla$ \\

Then I have another formula, but the indent must be bigger.

   $bla-bla-bla$ \linebreak

An so on. It looks like the depth of the recursion.

   $bla-bla-bla$ \\ 

      $bla-bla-bla$ \\

          $bla-bla-bla$ \\

   $bla-bla-bla$  \\

   $bla-bla-bla$  \\

        $bla-bla-bla$  \\

        $bla-bla-bla$   \\

How can I do it? I try to use \hspace, but it works only at the beginning.

share|improve this question
    
It seems to me as algorithmic could take place here. Are you writing an algoritm? What do you need this for? –  tohecz Apr 25 '12 at 12:31
    
it is just the picture of some call stack –  user565447 Apr 25 '12 at 13:01
    
Then I would recommend you to ask something like "How to display indented call stack" or similar, which points out your real target, and not the way you tried to solve it. That would allow the answers to better fit to your problem ;) See XY problem –  tohecz Apr 25 '12 at 13:14

2 Answers 2

up vote 3 down vote accepted

If you need it once or twice, you can stay with something like the following. The empty \hbox makes sure that the following skip (\quad in this case) is not ignored.

\documentclass{article}

\begin{document}

\noindent
$f(4)=f(3)+f(2)=5$
\\\hbox{}
\quad $f(3)=f(2)+f(1)=3$
\\\hbox{}
\quad\quad $f(2)=f(1)+f(0)=2$
\\\hbox{}
\quad\quad\quad $f(1)=1$
\\\hbox{}
\quad\quad\quad $f(0)=1$
\\\hbox{}
\quad\quad $f(1)=0$
\\\hbox{}
\quad $f(2)=f(1)+f(0)=2$
\\\hbox{}
\quad\quad $f(1)=1$
\\\hbox{}
\quad\quad $f(0)=1$

\end{document}
share|improve this answer
    
do not use \hbox (as that behaves differently within a paragraph and between paragraphs and for that reason is not a user-level LaTeX command). Use either \mbox{} or better \hspace*{1em} etc. –  Frank Mittelbach Apr 25 '12 at 14:50
    
@FrankMittelbach Is there any other reason why not to use \hbox{} here other than that it's a TeX primitive? And \hspace*{1em} seems to me as "too long", even though it might be shorter than \hbox{}\quad, that's why I provided this alternative to David's answer. –  tohecz Apr 25 '12 at 16:05
    
LaTeX has a fairly consistent user-level context in that it ensures that all text-producing commands always ensure that they are in horizontal mode, ie within a paragraph, if necessary by starting one. A primitive like \hboxdoesn't do this and that is giving users unnecessary surprises. For example if you would say, "use \hbox{word} to ensure that a certain word is not hyphenated" then this fails if it is the first word in a paragraph. Therefore those primitives should not be advertised as user-level commands and instead the LaTeX variants (in this case \mbox) should be suggested. –  Frank Mittelbach Apr 26 '12 at 10:54
    
I therefore suggest you alter your solution to use the latter. –  Frank Mittelbach Apr 26 '12 at 10:54

You could use \hspace* as the star form avoids the space being discarded at the start of a line, but using an environment designed for laying out such expressions is probably preferable. It is hard to say given your truncated example but perhaps tabbing or one of the amsmath alignments would be more suitable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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