3

I would like to use the &-symbol and reference (to sections) in the texts that are circled around the inner point but whenever I try to do this, the document compiles to infinity.

Minimal working example:

\documentclass{article}
\usepackage [ europeanresistors ]{ circuitikz }
\usepackage{tikz, pgfornament, tikzrput}
    \usetikzlibrary{shapes.geometric,arrows,decorations, decorations.text}
    \usepackage[textwidth=5cm,textheight=5cm,right=2.5cm,left=2.5cm]{geometry}
    \usepackage[T1]{fontenc}
    \usepackage{fix-cm}

\usepackage[colorlinks=true, allcolors=blue]{hyperref}

\begin{document}

\section{Introduction}\label{sec:intro}

\begin{figure}[htbp] \begin{tikzpicture}

\drawdouble distance=10mm circle (2.3cm); \node at (0,0,0,0) {This & that \ref{sec:intro}}; \path [postaction={decorate,decoration={text along path, reverse path,text align=center, text={||Inner Ring 1 }}}] (-36:2.3cm) arc (-36:216:2.3cm); \path [postaction={decorate,decoration={raise=-1ex,text along path, text align=right, text={||Inner Ring 2}}}] (-36:2.3cm) arc (-36:370:2.3cm); \path [postaction={decorate,decoration={raise=-1ex,text along path, text align=right, text={||Inner Ring 3}}}] (-36:2.3cm) arc (-36:220:2.3cm); %Not working: %\path [postaction={decorate,decoration={raise=-1ex,text along path, text align=right, text={||This & that \ref{sec:intro} 3}}}] (-36:2.3cm) arc (-36:220:2.3cm);

\end{tikzpicture} \caption{This is a circle} \label{fig:circle} \end{figure}

\end{document}

Output

Rmano
  • 40,848
  • 3
  • 64
  • 125
JuliePRE
  • 31
  • 2
  • 1
    This has really nothing to do with circuitikz. If you remove the \usepackage{circuitikz}, the result and the problem (which I don't know how to solve, sorry...) it's exactly the same. Please, try to reduce the thing to a minimal example. I'll fix the tags. – Rmano Mar 28 '24 at 10:36
  • 2
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – jlab Mar 28 '24 at 10:54

1 Answers1

3

There're two issues in the expression

This \& that \ref{sec:intro} 3

The first is the ampersand. The fix is easy, enclose it with braces:

This {\&} that \ref{sec:intro} 3

The second is the \ref. A workaround would be to convert the section number to a simple string. Following Why can't I expand \ref*{} as a string?, you can try:

\edef\introsectionnumber{\getrefnumber{sec:intro}}

before

This {\&} that \introsectionnumber{} 3

So this should work:

% working:
\edef\introsectionnumber{\getrefnumber{sec:intro}}
\path [postaction={decorate,decoration={raise=-1ex,text along path, text align=right, text={||This {\&} that \introsectionnumber{}  3}}}] (-36:2.3cm) arc (-36:220:2.3cm);
jlab
  • 1,834
  • 1
  • 13
  • Great, this works fine. But I guess there is no possibility to keep the hyperlink reference to the section? – JuliePRE Mar 28 '24 at 11:40
  • 1
    @JuliePRE Sorry, I'm afraid this is beyond my skills. – jlab Mar 28 '24 at 12:04
  • 1
    @JuliePRE that is another question. You should be able to prepare a very short minimum example for that; go ahead and post it! (The author of hyperref is often around; make an easy-to-answer question and maybe she knows how to solve it). – Rmano Mar 28 '24 at 18:56