11

i would like to bend a math formula around a circle. While it is working with text, LaTeX would not bend a formula in a math environment around a circle, at least, i hadn´t had success. The following code i wrote for a test:

\documentclass[convert={density=300,size=1080x800,outext=.png}]{standalone}
\usepackage{fontspec}
\usepackage{amssymb}
\usepackage{unicode-math}
\usepackage{xfrac}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{decorations.text,fit,chains,calc,shapes.geometric,intersections}
\usepackage[margin=15mm]{geometry}

\begin{document}
\begin{tikzpicture}
\begin{scope}[shift={(0cm,0cm)}, fill opacity=0.5, mytext/.style={text  opacity=1,font=\large\bfseries}]
% Kreise  
\draw[fill=red, draw = black] (0,0) circle (5); % Complex Numbers
\draw[fill=blue!10, draw = black,name path=circle 2] (0,0) circle (4.2);  % Imaginary Numbers
\end{scope}

\draw [ draw opacity=0.1, rotate=120,
   postaction={decorate, decoration={raise=-1ex,text along path,reverse path,text align={fit to path stretching spaces},
              text={|\ttfamily\huge\color{blue}|Outer\space Space       \space}}}] (0,0) circle (4.6cm);
\draw [draw opacity=0.1, rotate=180,
   postaction={ decorate, decoration={raise=-1ex,text along path,reverse path,text align={fit to path stretching spaces},
       text={|\ttfamily\huge\color{green}|Inner\space Space \space}}}] (0,0) circle (3.8cm);

\node at (4,0) (N) {\tiny 1,2,3,4};
\node[rotate=90] at (-3,1) (N) {$y(n)=h_0x(n)+h_1x(n-1)+\dots +h_{N-1}x(n-N+1)=\sum_{k=0}^{N-1}h_kx(n-k)$};
\end{tikzpicture}

\end{document}

The following result is generated, but the math formular is not bended.Math not bending

  • The accepted answer here may help: tex.stackexchange.com/questions/82867/… – Ethan Bolker Apr 26 '16 at 15:47
  • off-topic: I'd use \dots instead of \ldots between the plus signs. – Sigur Apr 26 '16 at 17:33
  • @Sigur, this formula was only an arbitrary example for the problem. Anyway, you are right, thank you! – Coliban Apr 27 '16 at 5:00
  • @Ethan, thank you, for the advice. But that answer uses an own tikzpicture-environment. As i commented also to Alain Mathes, i need a text bending around a path within or relative to a node. – Coliban Apr 27 '16 at 5:20
19

From the Manual !

• It is only possible to typeset text in math mode under considerable restrictions. Math mode is entered and exited using any character of category code 3 (e.g., in plain TEX this is $). Math subscripts and superscripts need to be contained within braces (e.g., {^y_i}) as do commands like \times or \cdot. However, even modestly complex mathematical typesetting is unlikely to be successful along a path (or even desirable).

\documentclass{article}

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

\begin{document}

\begin{tikzpicture}[decoration={text along path, text={$\ \ \ y(n)={h_0}x(n)+{h_1}x(n-1)+{\ldots} +{h_{N-1}}x(n-N+1)={\sum_{k=0}^{N-1}}{h_kx(n-k)}$}}]
  \path [decorate]
    (0,0) .. controls (0,6) and (9,6) .. (9,0);
\end{tikzpicture}
\end{document}

enter image description here

Update

\documentclass[margin=1cm]{standalone}
\usepackage{fontspec}
\usepackage{amssymb}
\usepackage{unicode-math}
\usepackage{xfrac}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{decorations.text,fit,chains,calc,shapes.geometric,intersections}

\begin{document}

\begin{tikzpicture}[
disk 1/.style={fill=red, draw = black},
disk 2/.style={fill=blue!10, draw = black,name path=circle 2},
disk 3/.style={
    rotate  = -90,
    postaction  = %
                 {decorate, 
                  decoration={raise = -1ex,
                              text along path,
                              reverse path,
                              text align = {fit to path stretching spaces},
                              text = {|\ttfamily\huge\color{blue}|
                                       Outer\space Space \space}}}},
disk 4/.style={
   draw opacity=0.1, 
   rotate=15,
   postaction={decorate,
               decoration={
                         raise=-1ex,
                         text along path,
                         reverse path,
                         text align={fit to path stretching spaces},
                         text={%
            |\color{red}| $y(n)={h_0}x(n)+{h_1}x(n-1)+{\cdots}+%
               {h_{N-1}}x(n-N+1)={\sum_{k=0}^{N-1}}{h_k}x(n-k)$ }
                              }
                        }
                }
    ]
\begin{scope}[  mytext/.style={text  opacity=1,
                font=\large\bfseries}]
% Disk 1
\draw[disk 1] (0,0) circle (5); 

% Disk 2
\draw[disk 2] (0,0) circle (4.2);
\end{scope}

% Disk 3
\path[disk 3] (0,0) circle (4.6cm);

% Disk 4
 \path[disk 4] (0,0) circle (3.8cm); 

\end{tikzpicture}
\end{document}

enter image description here

  • Beat me by 8 minutes. I will delete my answer! – Steven B. Segletes Apr 26 '16 at 17:32
  • Shouldn't cdots be used instead of lots (nice answer btw) – daleif Apr 26 '16 at 19:07
  • 1
    @daleif I used the formula from the question but yes you are right – Alain Matthes Apr 26 '16 at 19:10
  • That´s great, Alain! But it seems, that i am too ignorant to incorporate this. While the bending of the text works flawless within one tikzpicture environment, i had no success in bringing it into a node. But i need a node because i need to implement it in an already existing tikzpicture (and it is rather simpler to position the text inside a bigger picture). Maybe my original question wasn´t that clear, but i need the text to bend it around a node or something. Thank you! – Coliban Apr 27 '16 at 4:49
  • Ok, Alain Matthes, thank you very much, i appreciate your work! I can compile your solution in an seperate file, so your solution is the ultimate answer to my question, i accepted your answer. On the other hand, when i incorporate this solution in my original document (a lecture for some mathematics), the processor says "TeX capacity exceeded, sorry" :-), but that is a different story. Thank you very much! – Coliban Apr 27 '16 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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