Text FormattingText make the path of a letter

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Abdessamed
Posts: 6
Joined: Tue Sep 07, 2021 11:32 am

Text make the path of a letter

Post by Abdessamed »

Hello friends,

How can a text make the path of a letter, for example, "letter s".
Instead of taking a circle for the following code.

Code: Select all

\documentclass[landscape]{article}
%\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[absolute,overlay]{textpos}
\usepackage{listings}
\usepackage{xcolor}

\usepackage{tikz}
\usepgfmodule{decorations}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations.text}

\begin{document}
    \DeclareFixedFont{\pb}{T1}{pbk}{b}{n}{5cm}
    
    \mbox{}
    \begin{textblock*}{200mm}[0.2,0.5](67mm,33mm)
        
        \catcode`\|12
        \begin{tikzpicture}
            %\draw [help lines] (4,4)grid (0,2);
            \fill [draw=none,fill=none,
            postaction={decorate,decoration={raise=8pt,text along path,
                    text=around and around and around and around we go we go we go we go we go we go we go we go we go we go we go}}]
            (0,1) arc (180:-180:3.5cm and 2.4cm);
        \end{tikzpicture}
        
    \end{textblock*}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Text make the path of a letter

Post by Ijon Tichy »

To change the path, just change the (0,1) arc (180:-180:3.5cm and 2.4cm) part of the TikZ code. You can e.g. append one more arc

Code: Select all

\documentclass[landscape,english]{article}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[absolute,overlay]{textpos}

\usepackage{tikz}
\usepgfmodule{decorations}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations.text}

\begin{document}
    \DeclareFixedFont{\pb}{T1}{pbk}{b}{n}{5cm}
    
    \mbox{}
    \begin{textblock*}{200mm}[0.2,0.5](67mm,65mm)
        \begin{tikzpicture}
            \fill [draw=none,fill=none,
            postaction={decorate,decoration={raise=8pt,text along path,
                    text=around and around and around and around we go we go we go we go we go we go we go we go we go we go we go around and around and around and around we go we go we go we go we go we go we go we go we go we go we go}}]
            (0,1) arc (180:-90:3.5cm and 2.4cm) (3.5,-1.5) arc (90:300:3.5cm and 2.4cm);
        \end{tikzpicture}
    \end{textblock*}
\end{document}
to draw a kind of question mark.

Note: If the path is longer than the text, you it could happen, that it stops before the end coordinate is reached. If the text is longer than the path, not all text will be shown.

Note also: xcolor and graphicx are loaded by tikz. So it does not make much sense, to load it explicitly.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Abdessamed
Posts: 6
Joined: Tue Sep 07, 2021 11:32 am

Text make the path of a letter

Post by Abdessamed »

Thanks, Mr.Ijon Tichy

But as you mentioned before the path is longer than the text and I want also to inverse the path direction.

Big thanks teacher.
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Text make the path of a letter

Post by Ijon Tichy »

To change the direction either draw the path in another direction. The direction of an arc depends on the values on the sign of the start and stop angle. You may also use option reverse path. But this does not change the path direction itself but the text direction and placement. You can also stretch the text along the path. See section 50.7 of the tikz manual for more information about text decoration.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Abdessamed
Posts: 6
Joined: Tue Sep 07, 2021 11:32 am

Text make the path of a letter

Post by Abdessamed »

I will check the document.

If i find the solution, I'll share it here.
Abdessamed
Posts: 6
Joined: Tue Sep 07, 2021 11:32 am

Text make the path of a letter

Post by Abdessamed »

Mr. Ijon Tichy,

There is not exist section 50.4 in the document!
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Text make the path of a letter

Post by Ijon Tichy »

You are wrong. There is a section 50.7, "Text Decorations" on page 655ff in the manual I've linked in my last post.

The same manual should also be in your local tex installation. Otherwise it is not complete. In this case you should learn, how to install packages with documentation.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply