7

Recently I got the request to write a dissertation on the topic of quantum diagrammatic algebra. It was a fun LaTeX challenge as well, as there were plethora of custom glyphs I had to define in order to write the paper. For example, some of loops similar to ones in Louis Kauffman's 1987 paper State models and the Jones polynomial. At first my task seemed pretty plain. That was, until I compiled my code.

\documentclass[a4paper, 12pt]{extreport}

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{tikz}

\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{positioning}

\newcommand{\foo}[1]{%
\begin{tikzpicture}[#1]%
\begin{scope}
\clip (-1.5ex,0) rectangle (1.5ex,1.5ex);
\draw (0,0) circle(1.5ex);
\end{scope}
\end{tikzpicture}%
}

\begin{document}
I love \verb|\foo| \foo{}
\end{document}

enter image description here

Notice that the edges of my glyph are cut off, which displeases me greatly. I always valued beautiful documents and I want mine to be as good-looking as possible. To get the general idea of high-quality custom glyphs, take a look at this paper.

Please help me with this issue. To rehearse, I would like to know the best possible way of creating custom glyphs (so that they are compiled in their entirety). Thank you in advance.

8

EDIT

I found out about the knots package. Have you tried it? It seems to produce exactly what you want. Type texdoc knots in the terminal for further info (or use CTAN)

BACK TO THE QUESTION

So, you have to extend the clipping area, in order to accomodate the line stroke.

I changed:

 \clip (-1.58ex,0.01) rectangle (1.6ex,1.6ex);

So:

\documentclass[a4paper, 12pt]{extreport}

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{tikz}

\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{positioning}

\newcommand{\foo}[1]{%
\begin{tikzpicture}[#1]%
\begin{scope}
\clip (-1.58ex,0.01) rectangle (1.6ex,1.6ex);
\draw (0,0) circle(1.5ex);
\end{scope}
\end{tikzpicture}%
}

\begin{document}
I love \verb|\foo| \foo{}
\end{document}

Yields:

enter image description here

  • @GregorPerčič I added more info. Have you ever considered the knots package? – Moriambar May 6 '17 at 18:36
  • No, I didn't know about the knots package before. Thank you for telling me. My only concern is the compatibility; can knots be used to define glyphs as well (I'll find out sooner or later)? – Gregor Perčič May 6 '17 at 18:39
  • @GregorPerčič I don't understand what you mean by "glyphs". But the whole tikz ensemble of packages (knots is one of them) surely can do something for you. You just need to find the right tools. I think knots is one of them – Moriambar May 6 '17 at 18:41
  • 1
    I was afraid that knots macros weren't compatible with commands such as \newcommand. When a clash between a package and a command happens, nasty things are bound to occur. I had a bad experience with such incompatibility once, and it wasn't pretty (7 hours of debugging got the best of me; then I finally realised the two just weren't compatible). I think a "sub"-package shouldn't cause problems. Thank you for your dedication. – Gregor Perčič May 6 '17 at 18:45
10

Why clipping? Just draw an arc!

\documentclass[a4paper, 12pt]{extreport}

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{tikz}

\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{positioning}

\newcommand{\foo}[1][]{%
\begin{tikzpicture}[#1]%
\draw (0,0) arc(180:0:1.5ex);
\end{tikzpicture}%
}

\begin{document}
I love \verb|\foo| \foo
\end{document}

enter image description here

  • Thank you for your answer. Minutes after I wrote the question I realised the arc would do the thing much better, without "fine-tuning" that is. I decided not to report on my discovery as I was hoping to get a package which would be specifically made for drawing braid diagrams. @Moriambar was of great help at this point, as he introduced me to two lovely packages: knots and braids (the latter was meant for PGF2.10, but it works fine on 3.0.1a as well). With these two I don't have to use plain tikz anymore. Thank you for your care. LaTeX truly has a wonderful community! – Gregor Perčič May 7 '17 at 12:03

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.