7

The default text-decoration letters look a little bit squished together:

enter image description here

I can manually make them the way I want by changing gather to

g{\kern1pt a}{\kern1pt t}{\kern1pt h}{\kern1pt e}{\kern1pt r}{}

but this is tedious and annoying. (more so for longer decorations)

Is there an automatic method of tweaking all the letters apart?

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.text}
\tikzset{>=latex}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\draw[->, cyan!50!white, line width=1.5mm ] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\draw[decoration={text along path, text={|\sffamily|gather},text align={center},raise=0.2cm},decorate] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\end{scope}
\begin{scope}[yshift=-3cm]
\draw[->, cyan!50!white, line width=1.5mm ] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\draw[decoration={text along path, text={|\sffamily|g{\kern1pt a}{\kern1pt t}{\kern1pt h}{\kern1pt e}{\kern1pt r}{}},text align={center},raise=0.2cm},decorate] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\end{scope}
\end{tikzpicture}
\end{document}
3
  • microtype's \lsstyle would be a possibility
    – Robert
    Commented Feb 21, 2020 at 21:52
  • how do I find out more information on that?
    – Jason S
    Commented Feb 21, 2020 at 21:59
  • 3
    @Robert I confirm that text={|\lsstyle\sffamily|gather} does the job; can you write an answer?
    – egreg
    Commented Feb 21, 2020 at 22:01

3 Answers 3

6

Here is a solution with the text effects along path option of the decorations.text library. I increased the gap, you can manage it by changing the character widths={inner xsep=1pt} option.

screenshot

\documentclass[border=2mm,tikz]{standalone}

\usetikzlibrary{arrows, decorations.text}
\tikzset{>=latex}
\begin{document}
\begin{tikzpicture}[decoration={
                text effects along path,
                text={gather},
                text align=center,
                raise=0.2cm,
                text effects/.cd,
                characters={ text along path,font=\bf\sffamily},
                character widths={inner xsep=1pt}}]
\draw[->,cyan!50!white,text=black,line width=1.5mm,
preaction={decorate} ]
 (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\end{tikzpicture}
\end{document}
3
  • 1
    That is! The best answer so far which exploit all options for decorate text. +1!
    – Zarko
    Commented Feb 23, 2020 at 11:27
  • @Zarko Thanks you :_)
    – AndréC
    Commented Feb 23, 2020 at 11:33
  • @Zarko Also for me ...all answer are +1..also the answer of AndréC that use the specific code of TikZ and not like me when I use Mathcha. 😊😊😊
    – Sebastiano
    Commented Feb 23, 2020 at 12:57
6

What you are trying to achieve is called letterspacing, and one possibility would be to use the microtype package: It provides the commands \textls[<letterspacing amount>]{<text>} and \lsstyle. Since it doesn't seem to be possible to typeset text in the decoration if it appears inside an argument (or at least I couldn't find out how), only the latter can be used here:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.text}
\tikzset{>=latex}
\usepackage{microtype}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\draw[->, cyan!50!white, line width=1.5mm ] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\draw[decoration={text along path, text={|\sffamily\lsstyle|gather},text align={center},raise=0.2cm},decorate] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\end{scope}
\begin{scope}[yshift=-3cm]
\draw[->, cyan!50!white, line width=1.5mm ] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\draw[decoration={text along path, text={|\sffamily|g{\kern1pt a}{\kern1pt t}{\kern1pt h}{\kern1pt e}{\kern1pt r}{}},text align={center},raise=0.2cm},decorate] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\end{scope}
\end{tikzpicture}
\end{document}

gives

enter image description here

The letterspacing amount can be modified with the letterspace package option:

\usepackage[letterspace=150]{microtype}

where the number denotes thousandths of an em, so in this case 0.15em (the default is 0.1em). To change the letterspacing amount locally, you could define a new command:

\newcommand\ltsp[1]{\expandafter\def\csname MT@letterspace@\endcsname{#1}\lsstyle}

and use it like this: text={|\sffamily\ltsp{400}|gather}.

(Note that letterspacing with microtype works with pdflatex or lualatex, but not with xelatex.)

3
  • (i) does all fonts support microtype? If i remebrer correcztly not; (ii) how to set letterspace=150 locally, for example for this decoration only?
    – Zarko
    Commented Feb 22, 2020 at 16:41
  • @Zarko it works with all fonts with pdflatex and lualatex, see my edit
    – Robert
    Commented Feb 22, 2020 at 18:54
  • Thank you very much! Nice answer +1!
    – Zarko
    Commented Feb 22, 2020 at 19:22
4

Here I create a tokcycle package macro \spaceouttext{gap}{text} that, when invoked, creates the desired tokens in the package's token register named \cytoks. Thus, do the invocation prior to the \draw and pass \the\cytoks as the textual argument.

\documentclass[border=2mm]{standalone}
\usepackage{tikz,tokcycle}
\newcommand\spaceouttext[2]{%
  \tokcycle{\addcytoks{##1{\kern#1}}}%
  {\processtoks{##1}}%
  {\addcytoks{##1}}%
  {\addcytoks{##1{\kern#1}}}{#2}}
\usetikzlibrary{arrows, decorations.text}
\tikzset{>=latex}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\spaceouttext{4pt}{gather}
\draw[->, cyan!50!white, line width=1.5mm ] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\draw[decoration={text along path, text={|\sffamily|\the\cytoks},text align={center},raise=0.2cm},decorate] (6.8cm,-1.7) -- (9.5cm,-1.7) arc (-90:0:1.5) -- (11cm,1.5);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

3
  • Very intrigue solution. So far I wasn't aware for tokcycle ... I install it to my MikTeX with console, however testing your MWE gives error I can't find file tokcycle.tex'.`. Where is this file? I have recent (upgraded just now) MikTeX.
    – Zarko
    Commented Feb 22, 2020 at 19:45
  • @Zarko Miktex does not load the package properly, despite my efforts to communicate with them. Because the package runs in both LaTeX and plain TeX, the tokcycle.sty file should go in tex/latex/tokcycle, whereas tokcycle.tex should go in tex/generic/tokcycle. The files + documentation are available at https://ctan.org/pkg/tokcycle Commented Feb 22, 2020 at 20:50
  • 1
    Thank you for the info. That is pity, otherwise MikTeX is good maintained Hopefully this will be resolved soon. I will read documentation on the my first spare time.
    – Zarko
    Commented Feb 22, 2020 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .