在 TikZ 中激活德语语言包

在 TikZ 中激活德语语言包

仍然没有对这个问题的答案...希望有人可以帮助我。我想回答这个问题应该不难:

有人可以帮我激活这个文件的德语吗?

到目前为止,如果文本中有“ä”或“ö”或“ü”,我只会收到错误消息,并且正常的 babel 包似乎不起作用,但我对这个程序来说是个绝对的初学者。

TikZ 文件如下所示:

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{decorations.text}


%newly added but also doesnt fix the problem:
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf




\newcommand\mytext[5] % inner radius, outer radius, start angle, end angle, text
{%
    \path[decorate, decoration={text along path, text=#5, text align=center}] (#3:0.5*#1+0.5*#2) arc (#3:#4:0.5*#1+0.5*#2);
}

\begin{document}
    \footnotesize
    
    \begin{tikzpicture}[line join=round,line cap=round]
        % radii
        \def\ra{1.5}
        \def\rb{2.5}
        \def\rc{3.5}
        \def\rd{5.5}
        \def\re{6.5}
        % circles
        \foreach\i in {\ra,\rb,\rc,\rd,\re}
        {%
            \draw[thick] (0,0) circle (\i);
        }
        % lines
        \foreach\a/\i in {  0/\rd/,  30/0,    60/\rb,  90/0,   120/\rd, 150/0,%
            180/\rb,  210/\rd, 240/\ra, 270/\rd, 300/\rd, 330/\rd}
        {%
            \draw[thick] (\a:\i) -- (\a:\re);
        }
        % labels (and some german letters to generate the error-message)
        \mytext{1}  {\ra} {90} {30}{1üüüü}
        \mytext{1}  {\ra}{150} {90}{1öööö}
        \mytext{0}  {\ra}{390}{150}{1ääää}
        %
        \mytext{\ra}{\rb} {90} {30}{2}
        \mytext{\ra}{\rb}{150} {90}{2}
        \mytext{\ra}{\rb}{240}{150}{2}
        \mytext{\ra}{\rb}{390}{240}{2}
        %
        \mytext{\rb}{\rc} {60} {30}{3}
        \mytext{\rb}{\rc} {90} {60}{3}
        \mytext{\rb}{\rc}{150} {90}{3}
        \mytext{\rb}{\rc}{180}{150}{3}
        \mytext{\rb}{\rc}{240}{180}{3}
        \mytext{\rb}{\rc}{390}{240}{3}
        % and so on
        
        \mytext{\rc}{\rd} {60} {30}{4}
        \mytext{5.5}{2.75} {90} {60}{4}
        \mytext{4}{\rd} {90} {60}{4}
        \mytext{5}{2.75}{150} {90}{4}
        \mytext{4.5}{\rd}{150} {90}{4}
        \mytext{3.5}{\rd}{150} {90}{4}
        \mytext{\rc}{\rd}{180}{150}{4}
        \mytext{\rc}{\rd}{240}{180}{4}
        \mytext{\rc}{\rd}{390}{240}{4}
        
        
        % ...
        
        \mytext{\rd}{\re} {30} {0}{5}
        \mytext{\rd}{\re} {60} {30}{5}
        \mytext{\rd}{\re} {90} {60}{5}
        \mytext{\rd}{\re}{120} {90}{5}
        \mytext{\rd}{\re}{150}{120}{5}
        \mytext{\rd}{\re}{180}{150}{5}
        \mytext{\rd}{\re}{210}{180}{5}
        \mytext{\rd}{\re}{240}{210}{5}
        \mytext{\rd}{\re}{270}{240}{5}
        \mytext{\rd}{\re}{300}{270}{5}
        \mytext{\rd}{\re}{330}{300}{5}
        \mytext{\rd}{\re}{360}{330}{5}
        
    \end{tikzpicture}
\end{document}

我对整个程序还不太了解,我才刚刚开始使用它。

感谢您的帮助! :)

答案1

对于pdflatex, 的解析器text along path会与应该用括号括起来的重音字符完全混淆。但事实证明,如果发现两个连续的重音字符,混淆仍然存在,因此必须用双括号括起来。

\documentclass[border=2mm]{standalone}
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
\usepackage[ngerman]{babel} % this is needed for umlauts

\usepackage{tikz}
\usetikzlibrary{decorations.text,babel}

\newcommand\mytext[5] % inner radius, outer radius, start angle, end angle, text
{%
  \path[
    decorate,
    decoration={text along path, text={#5}, text align=center}
  ] (#3:0.5*#1+0.5*#2) arc (#3:#4:0.5*#1+0.5*#2);
}

\begin{document}

    \begin{tikzpicture}[line join=round,line cap=round]
        % radii
        \def\ra{1.5}
        \def\rb{2.5}
        \def\rc{3.5}
        \def\rd{5.5}
        \def\re{6.5}
        % circles
        \foreach\i in {\ra,\rb,\rc,\rd,\re}
        {%
            \draw[thick] (0,0) circle (\i);
        }
        % lines
        \foreach\a/\i in {  0/\rd/,  30/0,    60/\rb,  90/0,   120/\rd, 150/0,%
            180/\rb,  210/\rd, 240/\ra, 270/\rd, 300/\rd, 330/\rd}
        {%
            \draw[thick] (\a:\i) -- (\a:\re);
        }
        % labels (and some german letters to generate the error-message)
        \mytext{1}  {\ra} {90} {30}{1{{ü}}{{ö}}{{ä}}{{ö}}}
        \mytext{1}  {\ra}{150} {90}{fl{ü}gel}
        \mytext{0}  {\ra}{390}{150}{1{ä}}
        %
        \mytext{\ra}{\rb} {90} {30}{2}
        \mytext{\ra}{\rb}{150} {90}{2}
        \mytext{\ra}{\rb}{240}{150}{2}
        \mytext{\ra}{\rb}{390}{240}{2}
        %
        \mytext{\rb}{\rc} {60} {30}{3}
        \mytext{\rb}{\rc} {90} {60}{3}
        \mytext{\rb}{\rc}{150} {90}{3}
        \mytext{\rb}{\rc}{180}{150}{3}
        \mytext{\rb}{\rc}{240}{180}{3}
        \mytext{\rb}{\rc}{390}{240}{3}
        % and so on
        
        \mytext{\rc}{\rd} {60} {30}{4}
        \mytext{5.5}{2.75} {90} {60}{4}
        \mytext{4}{\rd} {90} {60}{4}
        \mytext{5}{2.75}{150} {90}{4}
        \mytext{4.5}{\rd}{150} {90}{4}
        \mytext{3.5}{\rd}{150} {90}{4}
        \mytext{\rc}{\rd}{180}{150}{4}
        \mytext{\rc}{\rd}{240}{180}{4}
        \mytext{\rc}{\rd}{390}{240}{4}
        
        
        % ...
        
        \mytext{\rd}{\re} {30} {0}{5}
        \mytext{\rd}{\re} {60} {30}{5}
        \mytext{\rd}{\re} {90} {60}{5}
        \mytext{\rd}{\re}{120} {90}{5}
        \mytext{\rd}{\re}{150}{120}{5}
        \mytext{\rd}{\re}{180}{150}{5}
        \mytext{\rd}{\re}{210}{180}{5}
        \mytext{\rd}{\re}{240}{210}{5}
        \mytext{\rd}{\re}{270}{240}{5}
        \mytext{\rd}{\re}{300}{270}{5}
        \mytext{\rd}{\re}{330}{300}{5}
        \mytext{\rd}{\re}{360}{330}{5}
        
    \end{tikzpicture}
\end{document}

在此处输入图片描述

正如所指出的vi pa 的评论,最好使用

text={#5}

所以如果文本包含逗号,您就不会遇到麻烦。

相关内容