Hi Stefan,
when I remove tikzpicture, I am successfully able to see the pdf document.
Attached the .tex file.
Graphics, Figures & Tables ⇒ Usage of TikZ with Lyx
Re: Usage of TikZ with Lyx
- Attachments
-
- 0-1 Knapsack.tex
- (6.22 KiB) Downloaded 249 times
- Stefan Kottwitz
- Site Admin
- Posts: 10311
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Usage of TikZ with Lyx
In the code, I can see that you use the turkish language, with babel. So, load the babel TikZ library in your preamble:
That's because turkish babel shortcut codes cause an issue with TikZ codes. \shorthandoff{=} after \begin{document} would also work, for the same reason, but then you could not use the "=" shortcut.
Stefan
Code: Select all
\usetikzlibrary{babel}
Stefan
LaTeX.org admin
Re: Usage of TikZ with Lyx
Thank you Stefan,
I got this worked.
\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}
]
\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}
I got this worked.
\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}
]
\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}