2

I am trying to calculate the width of a string defined by csname.

The MWE is here

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{calc}


\def\EllipseDegrees{120}
\def\EllipseOuterRadious{4}
\def\EllipseInnerRadious{3}


\newsavebox\mybox
\newlength{\mylengtho}
\newlength{\mylengtht}

\begin{document}

\begin{tikzpicture}
      \tikzset{
      partial ellipse/.style args={#1:#2:#3}{
          insert path={+ (#1:#3) arc (#1:#2:#3)}
      }
   }
   \draw (0,0) circle (3);
   \draw (0,0)
   [partial ellipse={180+\EllipseDegrees/2}:{180-\EllipseDegrees/2}:\EllipseOuterRadious cm and \EllipseInnerRadious cm];
   \pgfmathsetmacro\stepslines{5}
   \pgfmathsetmacro\degsteplines{\EllipseDegrees/\stepslines}

   \foreach \ellipsetext [count=\i from 1] in {First Value, Second Value, Third Value, Fourth value, Fifth value}{

      \global\expandafter\let\csname Item\i\endcsname\ellipsetext

      \xdef\myt{\csname LeftItem\i\endcsname}
      \savebox\mybox{\myt}
      \pgfmathsetmacro\myw{\wd\mybox}
      \node at (5,0) {myw=\myw};
      \global\expandafter\let\csname Item\i Width\endcsname\myw
   }

   \foreach \n in {1,...,5} {
   \xdef\curdeg{180-\EllipseDegrees/2+(\n-1)*\degsteplines}
   \pgfmathsetmacro\curdegfixed{\curdeg+(\degsteplines/2)}
   \savebox\mybox{\fontsize{10}{12}\selectfont\expandafter\csname Item\n\endcsname}
   \settowidth{\mylengtho}{\expandafter\widthof{\mybox}}
   \settowidth{\mylengtht}{\usebox{\mybox}}
   \global\expandafter\let\csname mylengthone\endcsname\mylengtht
   \global\expandafter\let\csname mywidthof\endcsname\mylengtho
   \pgfmathsetmacro\EllipseOuterRadiousfixed{\EllipseOuterRadious}
   \pgfmathsetmacro\EllipseInnerRadiousfixed{\EllipseInnerRadious}
    \node[rotate=180+\curdegfixed] at ($(0,0)+
      ({\EllipseOuterRadiousfixed*cos(\curdegfixed)},{\EllipseInnerRadiousfixed*sin(\curdegfixed)})$)
         {%
          \fontsize{10}{12}\selectfont \csname Item\n\endcsname 
         };
   }
   \node at (5,1) {thewdmybox=\the\wd\mybox};
   \node at (5,-1) {themylength=\the\mylengtho};
   \node at (5,2) {mywidthof=\expandafter\the\csname mywidthof\endcsname};
   \node at (5,3) {mywidthof=\expandafter\the\csname mylengthone\endcsname};
\end{tikzpicture}


\end{document}

The point is to add text radical (next to a circle) in elliptical way and alligned.

The result pdf is this:

enter image description here

I have done a part of the job described but I need length of every text of the list (kept with '\csname') to add the distances and correct my variables.

As you can see... next to the diagram I print every try made and all are zero!

Any idea?

koleygr
  • 20,105
  • just for them who will try it... I don't really need the text alligned there because anyway I am can do it and have more complex code to break lines too... My point is just to be able use the length on my calculations. Thanks for reading. – koleygr Aug 21 '17 at 12:21
  • 2
    Inside tikz the font is nullfont. You need to interrupt this: https://tex.stackexchange.com/a/56405/2388 – Ulrike Fischer Aug 21 '17 at 12:26
  • Thank you really much @UlrikeFischer I had no idea... will this work with \fontsize...\selectfont? If so you can mark it as a duplicate... or let me to change the question's title to "radical alligned text arround an ellipse" to be usefull for others too... – koleygr Aug 21 '17 at 12:30
  • PGF maths also has a width function for getting the width of text. – cfr Aug 21 '17 at 13:00
  • @cfr do you mean '\widthof{}'? – koleygr Aug 21 '17 at 13:04
  • 1
    @koleygr No. The macro version is \pgfmathwidth{}. The version in an expression is width(). – cfr Aug 21 '17 at 13:08

0 Answers0