2

To use stealth shaped arrow, I add this in preamble

\usetikzlibrary{shapes,arrows,chains,positioning,calc}
\usetikzlibrary{arrows.meta}

When compiling, the console gets stuck with (C:\MiKTex\tex\generic\pgf\frontendlayer\tikz\libraries\tikzlibraryautomata.code.tex) and there is no error message.

MWE:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,chains,positioning,calc}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}[scale=8]\centering \usetikzlibrary{automata,positioning} \tikzset{ %Define standard arrow tip >=stealth', %Define style for boxes punkt/.style={ rectangle, rounded corners, very thick, text width=6.5em, minimum width = 5em, minimum height=4em, text centered}, % Define arrow style pil/.style={ ->, thick, shorten <=2pt, shorten >=2pt,} }

\node [punkt, draw = blue] at (0,0) {$x>y$}; \node [punkt, draw = red] at (0.8, 0) {$x<y$};

% \node[] at (0.15, 0.03) (0up) {}; \node[] at (0.65, 0.03) (1up) {}; \path (0up) edge[pil, bend left=15] node [above] {A} (1up);

\node[] at (0.15, -0.03) (0down) {}; \node[] at (0.65, -0.03) (1down) {}; \path (1down) edge[pil, bend left=15] node [below] {B} (0down);

\end{tikzpicture}

\end{document}

My problem is that the MWE per se works well, but adding the same piece of code into my original tex file leads to the aforementioned problem.

Update: Finally found the the "MnonWE":

\documentclass[11pt]{article}
\usepackage{commath}
\usepackage{tikz}

% arrows in tikz \usetikzlibrary{shapes,arrows,chains,positioning,calc} \usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}[scale=8] \tikzset{ %Define standard arrow tip >=stealth', %Define style for boxes punkt/.style={ rectangle, rounded corners, very thick, text width=6.5em, minimum width = 5em, minimum height=4em, text centered}, % Define arrow style pil/.style={ ->, thick, shorten <=2pt, shorten >=2pt,} }

\node [punkt, draw = blue] at (0,0) {$\forall i:x_i>y_i$}; \node [punkt, draw = red] at (0.8, 0) {$\forall i:x_i<y_i$}; % \node[] at (0.15, 0.03) (0up) {}; \node[] at (0.65, 0.03) (1up) {}; \path (0up) edge[pil, bend left=15] node [above] {A} (1up);

\node[] at (0.15, -0.03) (0down) {}; \node[] at (0.65, -0.03) (1down) {}; \path (1down) edge[pil, bend left=15] node [below] {B} (0down);

\end{tikzpicture} \end{document}

So the file fails to compile only when \usepackage{commath} is included in preamble and $\forall i:x_i>y_i$ is used in the \node.

  • That's practically impossible to debug if you don't provide a minimal working example (MWE) (or non-working, in this case). – Rmano Jun 06 '21 at 18:34
  • Thanks! Just added a MWE. Weirdly, the problem does not show up in the MWE. – RandomBear Jun 06 '21 at 19:04
  • use >=Stealth. – vi pa Jun 06 '21 at 19:13
  • I tried this, but still the same compiling issue.. @vipa – RandomBear Jun 06 '21 at 19:21
  • 1
    It's not a good idea write \centering inside a tikzpicture, but compile instead for me. Even load a library inside a tikzpicture is not good IMHO. – vi pa Jun 06 '21 at 19:23
  • Do you compile with pdflatex? – vi pa Jun 06 '21 at 19:27
  • Removing \centering and \usetikzlibrary inside works fine in the MWE. In the original file, the compiling gets stuck, but there is no specific error message. I compiled with both PDFTexify and PDFLaTex, results are similar – RandomBear Jun 06 '21 at 19:34
  • I think it's a good idea to have all \usetikzlibrary in the preamble, even though it seems to work in your MWE. That said though, you'll need to make an MWE that actually demonstrates the problem I think. Start with a copy of your original file, and remove as much code as you can without removing the problem. – Torbjørn T. Jun 06 '21 at 19:36
  • Even with those incoherences in the code, it's compiling fine for me (with PDFLaTeX). – SebGlav Jun 06 '21 at 19:36
  • As said by TorbjørnT. starting from the bottom delete the code until you don't get errors. The last thing that you have deleted contain the error (debug tip). Or even better instead of delete comment the code with%. – vi pa Jun 06 '21 at 19:45
  • If the problem doesn't show up in the MWE, how do you think we can debug it ?(anyway, all the comments are correct...). Are you sure you are not nesting draw commands? \draw ... \node ... instead of \draw ... node ... can create an infinite loop... – Rmano Jun 06 '21 at 20:51
  • After a lot trials and errors, finally found the "MnonWE". Updated in the question. – RandomBear Jun 06 '21 at 21:20
  • "Compile gets stuck" usually means (La)TeX is waiting for some sort of input. Check you have all packages/libraries installed, no name misspelled, ... – vonbrand Jun 06 '21 at 21:52
  • 2
    For other who can/want to explain the problem, here is a MnonWE: \documentclass{article} \usepackage{commath} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node {$:$}; \end{tikzpicture} \end{document} – hpekristiansen Jun 06 '21 at 23:24
  • The commath manual says: "There is also one command included in the package which fixes the alignment of := in mathmode"... So probably it's making : active? – Rmano Jun 07 '21 at 06:17
  • @hpekristiansen found the culprit. I do not know how to revert it to normal after the fact, so I went for the sledgehammer solution... – Rmano Jun 07 '21 at 08:51

1 Answers1

2

I am testing with the neat @hpekristiansen MWE:

\documentclass{article}
\usepackage{commath}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
        \node {$:$};
    \end{tikzpicture}
\end{document}

The problem is this snippet of commath.sty (around line 280):

% Fix alignment of := in mathmode
\mathchardef\ordinarycolon\mathcode`\:
\mathcode`\:=\string"8000
\begingroup \catcode`\:=\active
   \gdef:{\mathrel{\mathop\ordinarycolon}}
\endgroup

which loops in a node text (not sure why). Probably it should be signaled to the package author to see if they can fix it.

For the time being, you can copy the file commath.sty to your current directory, and remove those lines.

Then it should work ok, even if you lose the := adjustment (which I would anyway do another way; playing with mathcodes and catcodes is, as you see, dangerous. It will surely do funny things with babel too).

Rmano
  • 40,848
  • 3
  • 64
  • 125