3

I accidentally copied and pasted the same code right below it. But the output is different. The second one has a strange omega attached to the triangle inside the set. Why is that? I copied it right below it again, and the omega shows up again. Based on the code, shouldn't the output be the same? Here is the code (credit to the second solution to my post here https://tex.stackexchange.com/a/653535/8650). Thanks in advance!

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {graphs}
\usetikzlibrary{quotes}
\tikzgraphsset{
empty nodes,
nodes={circle, draw, inner sep=0pt, minimum size=2pt},
counterclockwise, radius=6pt, phase=210,
}
\tikzset{
baseline=-2pt,
every label/.style={font=\tiny, inner sep=0pt},
dashed/.style={dash pattern=on 1pt off 1pt},
label distance=1pt,
}

\begin{document}

Let $\mathcal{H}$ be \{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3}\} and $\sigma$ be \tikz \graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};

Let $\mathcal{H}$ be \{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3}\} and $\sigma$ be \tikz \graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};


\end{document}

Edit: Here is a screenshot of the output output

Edit: code from https://tex.stackexchange.com/a/653535/277998

4
  • Can you please add a screenshot to your question?
    – MS-SPO
    Aug 11, 2022 at 4:11
  • 1
    @MS-SPO Yes, of course. Done! Aug 11, 2022 at 4:24
  • 1
    It is strange, that you choose to use my code(per comment in my answer) and yet you accept an other answer. And now you use my code in a question without as much as a reference to where you got the code. tex.stackexchange.com/a/653535/8650 Aug 11, 2022 at 5:08
  • @hpekristiansen Hi, sorry, I wish I could accept both answers. I found both helpful. I was hoping to use both—but ran into some trouble. This particular question concerns your code. I'm new to posting and wasn't sure if references are preferred. I'll fix that in my edit right away. Thank you for pointing it out. Aug 11, 2022 at 5:21

2 Answers 2

2

Looks like you have some typos in your two lines of content. First I split one line, to better localize the errors the compiler flagged, and commented out the second (your copy). Second, I corrected and copied the "new" content.

Just compare "your" and "my" tikz-statements; i.e. just use it like any other call to a macro (e.g. defined by a \newcommand) in running text:

\{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3}\}% yours

\tikz{\graph[n=3]{1,2,3;1--2,1--3,2--3}}% mine

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {graphs}
\usetikzlibrary{quotes}
\tikzgraphsset{
empty nodes,
nodes={circle, draw, inner sep=0pt, minimum size=2pt},
counterclockwise, radius=6pt, phase=210,
}
\tikzset{
baseline=-2pt,
every label/.style={font=\tiny, inner sep=0pt},
dashed/.style={dash pattern=on 1pt off 1pt},
label distance=1pt,
}

\begin{document}

Let $\mathcal{H}$ be 
\tikz{\graph[n=3]{1,2,3;1--2,1--3,2--3}} 
and $\sigma$ be 
\tikz{\graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};}


Let $\mathcal{H}$ be 
\tikz{\graph[n=3]{1,2,3;1--2,1--3,2--3}} 
and $\sigma$ be 
\tikz{\graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};}

%Let $\mathcal{H}$ be \{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3}\} and $\sigma$ be \tikz \graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};


\end{document}
5
  • It wasn't a typo though I meant for H to be a set that contains that graph. Is the set notation causing this problem? Aug 11, 2022 at 5:27
  • No, just the two tikz-statements do. You can check it, if you split your text-line as I did. Calling \tikz{} in running text isn't different from a users perspective to calling \textbf{someText} (for someText in bold) or an inline mathmode, like $\mathcal{H}$ . // I.e. there is no need, in fact it gives a compile error, to backslash the braces \{ or \} .
    – MS-SPO
    Aug 11, 2022 at 5:49
  • But I would need \{ \} to create a set, right? My output had the triangle associated with H appear in a set bracket (the first line of my output is what I want to show). I don't think yours have that. If \{ \} often gives an error, is there any way to get around that for the set notation/creating a set? Aug 11, 2022 at 6:01
  • 1
    Sorry, I just realized what you meant. I added \{ \} outside the \tikz code and broke up the inside of the code as you suggested. It's working now. Thank you! In fact, I think this solved my other problem as well. Thanks again! Aug 11, 2022 at 6:03
  • 1
    Great ! Latex is full of surprises and possibilities. Enjoy your ride.
    – MS-SPO
    Aug 11, 2022 at 6:11
4

A \tikz command should be delimited by a corresponding ;.

What happens with your code is that the first \tikz instruction is not properly delimited. I slightly reformatted the code (but this is not influential and just allows to be able to see the entire code on the screen)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {graphs}
\usetikzlibrary{quotes}

\tikzgraphsset{
  empty nodes,
  nodes={circle, draw, inner sep=0pt, minimum size=2pt},
  counterclockwise, radius=6pt, phase=210,
}
\tikzset{
  baseline=-2pt,
  every label/.style={font=\tiny, inner sep=0pt},
  dashed/.style={dash pattern=on 1pt off 1pt},
  label distance=1pt,
}

\begin{document}

Let $\mathcal{H}$ be \{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3}\} and 
$\sigma$ be \tikz \graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};

Let $\mathcal{H}$ be \{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3}\} and 
$\sigma$ be \tikz \graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};

\end{document}

When running LaTeX and going past errors we get

! Package tikz Error: Giving up on this path. Did you forget a semicolon?.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.20 ...{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3}\}
                                                   and
?

! Package tikz Error: Giving up on this path. Did you forget a semicolon?.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.23 ...{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3}\}
                                                   and
?

so you clearly see that something goes wrong with the first appearance of the graph in both paragraphs.

I guess that the Omega appears in the second instance because TikZ has been left in an unstable state. It has to do several global settings, and errors in one tikzpicture might lead to unexpected output in following ones. Why Omega? It's the character that sits at slot "0A in the standard font; something was left behind and the strange character appears (an Omega used to show in some Xy-pic diagrams, due to a bug, for instance).

If you switch to T1-encoded fonts the output is

enter image description here

(after the two error messages).

The conclusion is: never disregard error messages and terminate properly \tikz.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {graphs}
\usetikzlibrary{quotes}

\tikzgraphsset{
  empty nodes,
  nodes={circle, draw, inner sep=0pt, minimum size=2pt},
  counterclockwise, radius=6pt, phase=210,
}
\tikzset{
  baseline=-2pt,
  every label/.style={font=\tiny, inner sep=0pt},
  dashed/.style={dash pattern=on 1pt off 1pt},
  label distance=1pt,
}

\begin{document}

Let $\mathcal{H}$ be \{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3};\} and
$\sigma$ be \tikz \graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};

Let $\mathcal{H}$ be \{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3};\} and
$\sigma$ be \tikz \graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};

\end{document}

Note ;\}. No error and expected output. On the other hand, you should use math mode braces:

Let $\mathcal{H}$ be $\{\tikz \graph[n=3]{1,2,3;1--2,1--3,2--3};\}$ and
$\sigma$ be \tikz \graph[n=2, phase = 180] {1,2;2["2"'right],1["1"'left];1--2};

but it's a different concern.

enter image description here

You must log in to answer this question.

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