Graphics, Figures & Tables ⇒ Usage of TikZ with Lyx
Usage of TikZ with Lyx
Hello,
I would like some help regarding the usage of tikz with lyx. When I have simple tikz code, it works fine. If the tikz code becomes a little complex suc as including tikzset, I do get error. What is the cause of this error? I put the required packages to the preamble.
Thank you in advance, Kocan
I would like some help regarding the usage of tikz with lyx. When I have simple tikz code, it works fine. If the tikz code becomes a little complex suc as including tikzset, I do get error. What is the cause of this error? I put the required packages to the preamble.
Thank you in advance, Kocan
NEW: TikZ book now 40% off at Amazon.com for a short time.
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Usage of TikZ with Lyx
Hello Kocan,
welcome to the forum!
Best regards,
Stefan
welcome to the forum!
What error message do you get?
How is the code?
Best regards,
Stefan
LaTeX.org admin
Re: Usage of TikZ with Lyx
Hello Stefan,
Thank you accepting me to the forum.
This code successfully:
\begin{tikzpicture}
% Define the nodes (vertices)
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (A) at (0, 0) {1};
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (B) at (4, 0) {2};
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (C) at (2, 3) {3};
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (D) at (5, 4) {4};
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (E) at (1, 4) {5};
% Draw the edges with weights
\draw[thick] (A) -- (B) node[midway, below] {2};
\draw[thick] (A) -- (C) node[midway, left] {4};
\draw[thick] (B) -- (C) node[midway, right] {6};
\draw[thick] (C) -- (D) node[midway, above right] {3};
\draw[thick] (C) -- (E) node[midway, left] {5};
\draw[thick] (D) -- (E) node[midway, below right] {1};
\end{tikzpicture}
Here is the failing code :
error = "TeX capacity exceeded, sorry [input stack size=10000]."
If I move tikzset to preamble, it works for this example.
I am also getting the same error I wanted to put some vertices into a cloud.
\begin{tikzpicture}
\tikzset{
% Style for nodes (vertices)
mynode/.style={
circle,
draw=blue,
fill=blue!20,
minimum size=15mm,
font=\large
},
% Style for edges
myedge/.style={
thick,
draw=black
},
% Style for edge weights
myweight/.style={
midway,
font=\small,
sloped
}
}
% Define the nodes (vertices)
\node[mynode] (A) at (0, 0) {1};
\node[mynode] (B) at (4, 0) {2};
\node[mynode] (C) at (2, 3) {3};
\node[mynode] (D) at (5, 4) {4};
\node[mynode] (E) at (1, 4) {5};
% Draw the edges with weights
\draw[myedge] (A) -- (B) node[myweight] {2};
\draw[myedge] (A) -- (C) node[myweight] {4};
\draw[myedge] (B) -- (C) node[myweight] {6};
\draw[myedge] (C) -- (D) node[myweight] {3};
\draw[myedge] (C) -- (E) node[myweight] {5};
\draw[myedge] (D) -- (E) node[myweight] {1};
\end{tikzpicture}
Thank you for your help. , Fatih
Thank you accepting me to the forum.
This code successfully:
\begin{tikzpicture}
% Define the nodes (vertices)
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (A) at (0, 0) {1};
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (B) at (4, 0) {2};
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (C) at (2, 3) {3};
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (D) at (5, 4) {4};
\node[circle, draw=blue, fill=blue!20, minimum size=15mm] (E) at (1, 4) {5};
% Draw the edges with weights
\draw[thick] (A) -- (B) node[midway, below] {2};
\draw[thick] (A) -- (C) node[midway, left] {4};
\draw[thick] (B) -- (C) node[midway, right] {6};
\draw[thick] (C) -- (D) node[midway, above right] {3};
\draw[thick] (C) -- (E) node[midway, left] {5};
\draw[thick] (D) -- (E) node[midway, below right] {1};
\end{tikzpicture}
Here is the failing code :
error = "TeX capacity exceeded, sorry [input stack size=10000]."
If I move tikzset to preamble, it works for this example.
I am also getting the same error I wanted to put some vertices into a cloud.
\begin{tikzpicture}
\tikzset{
% Style for nodes (vertices)
mynode/.style={
circle,
draw=blue,
fill=blue!20,
minimum size=15mm,
font=\large
},
% Style for edges
myedge/.style={
thick,
draw=black
},
% Style for edge weights
myweight/.style={
midway,
font=\small,
sloped
}
}
% Define the nodes (vertices)
\node[mynode] (A) at (0, 0) {1};
\node[mynode] (B) at (4, 0) {2};
\node[mynode] (C) at (2, 3) {3};
\node[mynode] (D) at (5, 4) {4};
\node[mynode] (E) at (1, 4) {5};
% Draw the edges with weights
\draw[myedge] (A) -- (B) node[myweight] {2};
\draw[myedge] (A) -- (C) node[myweight] {4};
\draw[myedge] (B) -- (C) node[myweight] {6};
\draw[myedge] (C) -- (D) node[myweight] {3};
\draw[myedge] (C) -- (E) node[myweight] {5};
\draw[myedge] (D) -- (E) node[myweight] {1};
\end{tikzpicture}
Thank you for your help. , Fatih
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Usage of TikZ with Lyx
Hi Fatih,
when you copy code into ERTs, line breaks are not preserved, so the code after the % comment is not seen as LyX considers it commented out. (similar seen here)
Try without the comments like "% Style for nodes (vertices)" etc., at least for testing.
Stefan
when you copy code into ERTs, line breaks are not preserved, so the code after the % comment is not seen as LyX considers it commented out. (similar seen here)
Try without the comments like "% Style for nodes (vertices)" etc., at least for testing.
Stefan
LaTeX.org admin
Re: Usage of TikZ with Lyx
Hi Stefan,
"Illegal parameter number in definition of \pgfkeyscurrentkey." this is the error for the following tikz code:
\begin{tikzpicture}
\tikzset{
vertex/.style={circle, draw=black, fill=blue!30, minimum size=1.2cm, font=\bfseries},
edge/.style={thick},
weight/.style={font=\small, fill=white, inner sep=1pt}
}
\node (A) [vertex, fill=green!50] at (0,2) {A};
\node (B) [vertex, fill=green!50] at (4,2) {B};
\node (C) [vertex, fill=green!50] at (0,0) {C};
\node (D) [vertex, fill=green!50] at (4,0) {D};
\node (E) [vertex, fill=green!50] at (6,1) {E};
\draw[edge] (A) -- node[weight] {4} (B);
\draw[edge] (A) -- node[weight] {1} (C);
\draw[edge] (B) -- node[weight] {2} (D);
\draw[edge] (C) -- node[weight] {4} (D);
\draw[edge] (B) -- node[weight] {5} (E);
\draw[edge] (D) -- node[weight] {3} (E);
\node at ($(A) + (0,0.8)$) {\textbf{0}};
\node at ($(B) + (0,0.8)$) {\textbf{4}};
\node at ($(C) + (0,-0.8)$) {\textbf{1}};
\node at ($(D) + (0,0.8)$) {\textbf{5}};
\node at ($(E) + (0,-0.8)$) {\textbf{8}};
\end{tikzpicture}
Best regards, Fatih
"Illegal parameter number in definition of \pgfkeyscurrentkey." this is the error for the following tikz code:
\begin{tikzpicture}
\tikzset{
vertex/.style={circle, draw=black, fill=blue!30, minimum size=1.2cm, font=\bfseries},
edge/.style={thick},
weight/.style={font=\small, fill=white, inner sep=1pt}
}
\node (A) [vertex, fill=green!50] at (0,2) {A};
\node (B) [vertex, fill=green!50] at (4,2) {B};
\node (C) [vertex, fill=green!50] at (0,0) {C};
\node (D) [vertex, fill=green!50] at (4,0) {D};
\node (E) [vertex, fill=green!50] at (6,1) {E};
\draw[edge] (A) -- node[weight] {4} (B);
\draw[edge] (A) -- node[weight] {1} (C);
\draw[edge] (B) -- node[weight] {2} (D);
\draw[edge] (C) -- node[weight] {4} (D);
\draw[edge] (B) -- node[weight] {5} (E);
\draw[edge] (D) -- node[weight] {3} (E);
\node at ($(A) + (0,0.8)$) {\textbf{0}};
\node at ($(B) + (0,0.8)$) {\textbf{4}};
\node at ($(C) + (0,-0.8)$) {\textbf{1}};
\node at ($(D) + (0,0.8)$) {\textbf{5}};
\node at ($(E) + (0,-0.8)$) {\textbf{8}};
\end{tikzpicture}
Best regards, Fatih
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Usage of TikZ with Lyx
Instead of \tikzset, you can use it in square brackets as options:
Does this help?
Stefan
Code: Select all
Code, edit and compile here:
\begin{tikzpicture}[vertex/.style = {circle, draw=black, fill=blue!30,minimum size=1.2cm, font=\bfseries},edge/.style = {thick},weight/.style = {font=\small, fill=white, inner sep=1pt}]...\end{tikzpicture}
Stefan
LaTeX.org admin
Re: Usage of TikZ with Lyx
Hi Stefan,
I received the same error:
"Illegal parameter number in definition of \pgfkeyscurrentkey."
Thank you in advance,
Fatih
I received the same error:
"Illegal parameter number in definition of \pgfkeyscurrentkey."
Thank you in advance,
Fatih
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Usage of TikZ with Lyx
Can you perhaps post the .log file, so we see the full context of that error and where it occurs exactly?
Stefan
Stefan
LaTeX.org admin
Re: Usage of TikZ with Lyx
Sorry. it took awhile to find the log file.
Code: Select all
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex 2023.2.2) 15 MAR 2025 20:30entering extended moderestricted \write18 enabled.%&-line parsing enabled.**0-1_Knapsack.tex(./0-1_Knapsack.texLaTeX2e <2022-11-01> patch level 1L3 programming layer <2023-01-24>(c:/texlive/2022/texmf-dist/tex/latex/base/article.clsDocument Class: article 2022/07/02 v1.4n Standard LaTeX document class(c:/texlive/2022/texmf-dist/tex/latex/base/size10.cloFile: size10.clo 2022/07/02 v1.4n Standard LaTeX file (size option))\c@part=\count185\c@section=\count186\c@subsection=\count187\c@subsubsection=\count188\c@paragraph=\count189\c@subparagraph=\count190\c@figure=\count191\c@table=\count192\abovecaptionskip=\skip48\belowcaptionskip=\skip49\bibindent=\dimen140) (c:/texlive/2022/texmf-dist/tex/latex/base/fontenc.styPackage: fontenc 2021/04/29 v2.0v Standard LaTeX package) (c:/texlive/2022/texmf-dist/tex/latex/base/inputenc.styPackage: inputenc 2021/02/14 v1.3d Input encoding file\inpenc@prehook=\toks16\inpenc@posthook=\toks17) (c:/texlive/2022/texmf-dist/tex/latex/amsmath/amsmath.styPackage: amsmath 2022/04/08 v2.17n AMS math features\@mathmargin=\skip50For additional information on amsmath, use the `?' option.(c:/texlive/2022/texmf-dist/tex/latex/amsmath/amstext.styPackage: amstext 2021/08/26 v2.01 AMS text(c:/texlive/2022/texmf-dist/tex/latex/amsmath/amsgen.styFile: amsgen.sty 1999/11/30 v2.0 generic functions\@emptytoks=\toks18\ex@=\dimen141)) (c:/texlive/2022/texmf-dist/tex/latex/amsmath/amsbsy.sty
- Stefan Kottwitz
- Site Admin
- Posts: 10323
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Usage of TikZ with Lyx
The error is in 0-1_Knapsack.tex, can you post the file here as attachment? Or if it's short, directly in the post.
Stefan
Stefan
LaTeX.org admin