TransWikia.com

German ß in tikzpicture with text decoration - Package inputenc Error: Invalid UTF-8 byte

TeX - LaTeX Asked on June 27, 2021

I wonder why I can’t use the ß directly at this point: decoration={text={heißer Dampf}. If I do that, pdflatex throws me an error: "Package inputenc Error: Invalid UTF-8 byte". I can’t understand why it doesn’t work with the decoration texts. The workaround is to replace the ß with { ss}, but it’s unsatisfactory. What is the problem with the implementation of the decorative texts and UTF8?

   documentclass{standalone}
   usepackage[utf8]{inputenc}%Die Textdateien sind mit Unicode-Kodierung
   usepackage{pgf,tikz}
   usetikzlibrary{mindmap,shadows,positioning,fit,petri,backgrounds,shapes,arrows,through,calc,decorations.text,decorations.markings,intersections,fpu,circuits.ee.IEC,babel}
        
        
    begin{document}
        begin{tikzpicture}
            [node distance=3cm and 3cm,on grid,auto,align=center,thick,
            Schritt/.style={rectangle,
                draw=black,inner sep=5pt,
                execute at begin node=hspace{0pt},%allow first word to break
            },
            Pfeil/.style={>=latex, ultra thick,->,bend angle=35, bend left, postaction=decorate,
                decoration={raise=4pt, text align=center, text along path}}
            ]
            begin{scope}
                node (Mitte) {};%Hilfsnode für die Mitte
                node[Schritt] (Schritt1) [above=of Mitte] {großer Dampferzeuger};
                node[Schritt] (Schritt2) [right=of Mitte] {Turbine};
                node[Schritt] (Schritt3) [below=of Mitte] {Kondensator};
                node[Schritt] (Schritt4) [left=of Mitte]  {Kesselwasser-speisepumpe};
                
                draw [Pfeil,decoration={text={hei{ss}er Dampf}}]          (Schritt1) to (Schritt2);
                draw [Pfeil,decoration={text={warmer Dampf},reverse path}] (Schritt2) to (Schritt3);
                draw [Pfeil,decoration={text={Wasser},reverse path}]       (Schritt3) to (Schritt4);
                draw [Pfeil,decoration={text={Wasser}}]                    (Schritt4) to (Schritt1);
                
            end{scope}
        end{tikzpicture}
    end{document}

One Answer

decorations works token by token, and as the ß consists of two bytes in utf8 it is split. It works if you protect it with a brace:

documentclass{standalone}
   usepackage[utf8]{inputenc}%Die Textdateien sind mit Unicode-Kodierung
   usepackage{pgf,tikz}
   usetikzlibrary{mindmap,shadows,positioning,fit,petri,backgrounds,shapes,arrows,through,calc,decorations.text,decorations.markings,intersections,fpu,circuits.ee.IEC,babel}


    begin{document}
        begin{tikzpicture}
            [node distance=3cm and 3cm,on grid,auto,align=center,thick,
            Schritt/.style={rectangle,
                draw=black,inner sep=5pt,
                execute at begin node=hspace{0pt},%allow first word to break
            },
            Pfeil/.style={>=latex, ultra thick,->,bend angle=35, bend left, postaction=decorate,
                decoration={raise=4pt, text align=center, text along path}}
            ]
            begin{scope}
                node (Mitte) {};%Hilfsnode für die Mitte
                node[Schritt] (Schritt1) [above=of Mitte] {großer Dampferzeuger};
                node[Schritt] (Schritt2) [right=of Mitte] {Turbine};
                node[Schritt] (Schritt3) [below=of Mitte] {Kondensator};
                node[Schritt] (Schritt4) [left=of Mitte]  {Kesselwasser-speisepumpe};

                draw [Pfeil,decoration={text={hei{ß}er Dampf}}]          (Schritt1) to (Schritt2);
                draw [Pfeil,decoration={text={warmer Dampf},reverse path}] (Schritt2) to (Schritt3);
                draw [Pfeil,decoration={text={Wasser},reverse path}]       (Schritt3) to (Schritt4);
                draw [Pfeil,decoration={text={Wasser}}]                    (Schritt4) to (Schritt1);

            end{scope}
        end{tikzpicture}
    end{document}

Answered by Ulrike Fischer on June 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP