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'm havin an issue which I cannot solve. If I have a subsubsection containing text with a verbatim section in between, the first line after the verbatim section is not aligned properly. If I put a \newline command after the verbatim, everything works, but it shows the error

There's no line here to end

This is the code:

\subsubsection{Umsetzung}
    C: \texttt{if(r1 > r2)$\{$statement;$\}$} \newline
    Realisierung in 2 Schritten: zuerst die Register vergleichen, dann auf Grund
    von Flags bedingten Sprung ausführen.
    \begin{verbatim}
        cp r1, r2   ; vergleiche (compare) r1 mit r1
        brge L1     ; verzweige falls r1 >= r2 (mit Vorzeichen!)
        ...
        statement
        ...
        L1: nop         ; hier geht es weiter
    \end{verbatim}

    C: \texttt{if(r1 > r2)$\{$statement1;$\}$else$\{$statement2;$\}$} \newline
    Assembler:
    \begin{verbatim}
        cp r1, r2   ; vergleiche (compare) r1 mit r
        brge L1     ; verzweige falls r1 >= r2
        ...
        statement1
        ...
        rjmp L2
        L1: ...
        statement2
        ...
        L2: ...      ; hier geht es weiter
    \end{verbatim}

And this is the output:

enter image description here

Even if I remove the whole verbatim section, the described line stays on a new line and not properly aligned (and this - in my oppinion - is far stranger, shouldn't it just float at the end of the previous sentence since I never tell to break a line?).

enter image description here

Note that I slightly formatted the content of the verbatim sections here for better legibility, so don't be suprised if the alignment of the Assembler-code isn't like in the picture in case you compile my code.

share|improve this question
1  
It isn't clear what error you see. C is starting a new paragraph and so gets parindent. Perhaps you want to set parindent to 0pt, or use \noindent ? Or just omit the blank line which is causing the new paragraph if you do not want a paragraph break at that point. –  David Carlisle Dec 12 '12 at 23:27
    
Instead of the mixed modes \texttt and $...$, use \verb|...|. –  Werner Dec 12 '12 at 23:29
add comment

1 Answer 1

up vote 4 down vote accepted

You should try one of three things:

  • remove the empty line before the line you don't want indented
  • put \noindent before your new line, or
  • put \hspace*{\fill}\newline

The way your MWE is written, you've told LaTeX that you're staring a new paragraph. If that's what you really want to do then the indentation is technically correct. If you don't want paragraphs indented or you don't want just this paragraph indented, then you can use \noindent. (Incidentally, LaTeX doesn't automatically indent the first paragraph after a section header.)

\newline doesn't like to end empty lines: hence the \hspace*{\fill} before it. I would recommend not using \newline because you're creating even more white space.

share|improve this answer
    
obviously it was the indentation. I was so deadlocked in searching the reason in some fancy error, that I did not considered this. Thank you! –  Valentino Ru Dec 13 '12 at 0:39
add comment

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.