0

Could someone tell me why LaTeX adds a linebreak after stanza 11?

[Edit: sorry, I think I should have used \par instead of double backslash

\getroot{§10§} \par
\getroot{§11§} \par
\getroot{§12§} \par  

So no need to read on ...

Edit2: But if I put \setlength{\parindent}{0pt} than the problem persists. So comments still appreciated!

I am reading the stanzas as plain text from an external file line by line (one stanza = one line) via a self defined command. The "entries" look like this:

§11§~{Der einzige Führer der im Dasein Umherwandern hat mit seinem grenzenlosen Verstand aufgrund genauer und vollständiger Untersuchung den großen Wert [dieser Geisteshaltung erkannt]. Die sich von der Existenz der Welt befreien möchten, sollten deshalb den kostbaren Erleuchtungsgeist fest im Herzen bewahren.}
§
§12§~{Andere Arten des Heilsamen gleichen der Bananenstaude: Sie vergehen, nachdem sie ihre Früchte hervorgebracht haben. Doch der wunscherfüllende Baum in Gestalt des Erleuchtungsgeistes mag immerzu seine Früchte hervorbringen, und doch vermehren sie sich noch, ohne jemals zu versiegen.}
§
§13§~{.... etc.}

And the tex-file Looks simply like this:

 ...
\getstanza{§11§} \\
\getstanza{§12§} \\
\getstanza{§13§} \\
 ...

Is this a "normal" LaTeX behaviour when a line is filled or is due to some error in the text inserting function? The text is just plainly added (wrapped in the curly brackets).

Edit:

ok, here is the source file. Sorry, it's long ... So, what makes the difference is related with the macro \getroot{}. It fetches the root stanzas from an external text file roots-db.txt. The point is that the text is formatted differently if it is taken from the external file, or - with exactly the same code (string functions) - from within this source file. You see the part "filecontents" representing my data file as "fake". If I comment that part out and use the real external file roots-db.txt instead, the resultant formatting is different! Any idea why?

What you see in the print of stanza 11, same text:

  1. printed with \getroot{§11§} with string data from the external file
  2. printed with the same string function, but with string from within the Latex file
  3. printed with manual formatting

    % <-- coding: utf-8 -- \documentclass[a4paper,12pt,twoside,parindent,smallheadings,pointednumbers,1.25headlines, nochapterprefix,headinclude,footexclude,mpinclude]{scrbook}

    \usepackage{scrpage2}
    \setkomafont{sectioning}{\bfseries\rmfamily}
    
    \usepackage{calc}
    \usepackage{xcolor}
    \usepackage{typearea}
    \areaset[0mm]{13.5cm}{24cm} % selbst setzen
    
    \usepackage{fontspec}
    \setmainfont[Mapping=tex-text]{Junicode} 
    \defaultfontfeatures{Mapping=tex-text}
    \usepackage{polyglossia} 
    \setdefaultlanguage[spelling=new, babelshorthands=true]{german}
    
    \renewcommand{\baselinestretch}{1.1} 
    \clubpenalty=10000 \widowpenalty=10000
    
    \parskip2ex
    \parindent0mm
    \raggedbottom
    \setlength{\marginparwidth}{0.7\marginparwidth}
    \setlength{\headheight}{1.1\baselineskip} % von Komaskript empfohlen
    
    %% Kopfzeilen:
    \pagestyle{scrheadings}
    \lehead{Eintritt in das Leben zur Erleuchtung}
    \rohead{\leftmark}
    \setheadwidth[0pt]{textwithmarginpar}  
    \setheadsepline{0.4pt}[]
    %% Fußzeilen:
    \lefoot{\pagemark}
    \rofoot{\pagemark}
    \setfootwidth[0pt]{head}
    
    \usepackage{filecontents}
    
    \begin{filecontents*}{roots-db.txt}
    §
    §10§~{Gleich einem golderzeugenden Elixier von besonderer Art wandelt [jenes Elixier], das man "`Erleuchtungsgeist"' nennt, diesen unreinen Körper, den wir angenommen haben, in einen kostbaren Buddha-Körper von unschätzbarem Wert. Halte also mit aller Kraft daran fest!}
    §
    §11§~{Der einzige Führer der im Dasein Umherwandern hat mit seinem grenzenlosen Verstand aufgrund genauer und vollständiger Untersuchung den großen Wert [dieser Geisteshaltung erkannt]. Die sich von der Existenz der Welt befreien möchten, sollten deshalb den kostbaren Erleuchtungsgeist fest im Herzen bewahren.}
    §
    §12§~{Andere Arten des Heilsamen gleichen der Bananenstaude: Sie vergehen, nachdem sie ihre Früchte hervorgebracht haben. Doch der wunscherfüllende Baum in Gestalt des Erleuchtungsgeistes mag immerzu seine Früchte hervorbringen, und doch vermehren sie sich noch, ohne jemals zu versiegen.}
    §
    \end{filecontents*}
    
    \usepackage{xstring}
    \usepackage{xifthen}
    
    \newcommand*{\isinxp}[2]{\expandafter\isinxpp\expandafter{#2}{#1}}
    \newcommand*{\isinxpp}[2]{\isin {#2}{#1}}
    
    \newread\dbroot
    \newcommand{\getroot}[1]{%
    \openin\dbroot=roots-db.txt
    \loop
        \read\dbroot to \dbline
        \unless\ifeof\dbroot
        \ifthenelse{\isinxp{#1}{\dbline}}
        {\StrCut{\dbline}{~}{\colA}{\colB}
        \StrBetween[1,2]{\colA}{§}{§}.~\colB}
        {}
    \repeat
    \closein\dbroot%
    }
    
    \begin{document}
    
    \chapter*{Eintritt in das Leben zur Erleuchtung}
    \section*{1. Die Vorzüge des Erleuchtungsgeistes}
    
    First Page
    \newpage
    
    \getroot{§11§} 
    
    11.~{Der einzige Führer der im Dasein Umherwandern hat mit seinem grenzenlosen Verstand aufgrund genauer und vollständiger Untersuchung den großen Wert [dieser Geisteshaltung erkannt]. Die sich von der Existenz der Welt befreien möchten, sollten deshalb den kostbaren Erleuchtungsgeist fest im Herzen bewahren.}
    
    \def\dbline{§11§~{Der einzige Führer der im Dasein Umherwandern hat mit seinem grenzenlosen Verstand aufgrund genauer und vollständiger Untersuchung den großen Wert [dieser Geisteshaltung erkannt]. Die sich von der Existenz der Welt befreien möchten, sollten deshalb den kostbaren Erleuchtungsgeist fest im Herzen bewahren.}}
    
    \StrCut{\dbline}{~}{\colA}{\colB}
    \StrBetween[1,2]{\colA}{§}{§}.~\colB \par 
    
    \getroot{§12§} \par
    
    \end{document}
    

Output, same data, different formatting

Christof
  • 460
  • First of all please post something the rest of us can test, i.e. a minimal example. What is \getroot or \getstanza? – daleif Feb 21 '14 at 14:57
  • These are a bit more complex commands, but basically they just get the plain text in {} from an external file. – Christof Feb 21 '14 at 15:02
  • My suggestion, without having something to play around with, is to use \rlap{.} for the ending period in §11§. – Werner Feb 21 '14 at 15:04
  • Thanks, just tried, but \rlap{.} doesn't change anything. – Christof Feb 21 '14 at 15:09
  • @Christof, still without having something to test with, how are we going to help? – daleif Feb 21 '14 at 15:46
  • The cause of the problem is your wrong usage of \\ to end paragraphs. Use \par or, even more clearly, an empty line. – egreg Feb 21 '14 at 15:48
  • \ or \par (with \parindent0pt) or blank line -> same result. @daleif: I'll try to set up a test file with exactly the same Parameters. Takes some time because my original file inputs different other files. – Christof Feb 21 '14 at 16:25
  • added the source code to my post. – Christof Feb 21 '14 at 17:36
  • If I put an hard space ~ at the end of the textline that is read from the external file, than the problem disappears. – Christof Feb 21 '14 at 22:17
  • @Christof First of all it might be an idea to mark this with xelatex as well. Compiles and works well if I remove the xelatex specific lines. Is it only with the Junicode font? I do not have that font, so I cannot test – daleif Feb 24 '14 at 09:04
  • @daleif Its with any font (outcomment \setmainfont) whenever the last line of the paragraph is "long enough". When a line of text is read from the external source file (which has the format {bla bla.}) and it results in a long last line in the paragraph the phenomena appears. If I add a space to the source {bla bla.~} it disappears. I don't understand why but at least it helps. – Christof Feb 24 '14 at 11:43
  • In that case do you mind updating the example such that it does not depend on xelatex stuff. Then I think it may be easier to attract help from others. – daleif Feb 24 '14 at 12:54
  • @daleif Sorry, it was a problem in my macro that added some spaces to the text. The lines \StrBetween[1,2]{\colA}{§}{§}.~\colB}% and {}% both need a % at the end. The problem has been discussed and solved in another threat: http://tex.stackexchange.com/questions/161590/string-comparison-in-ifthenelse – Christof Feb 25 '14 at 22:16

0 Answers0