Unable to compile basic tikz codes from pgfmanual












0















In last semester, I started using LaTeX just for assignments and homework but now I wanted to take to the next level.



I started with the tikz library following the pgfmanual. Everytime I try to compile my code I get different result from the documentation, or it won't even compile.



For example this first code I copied it right from the documentation



    documentclass{standalone}
usepackage{tikz}

begin{document}

begin{tikzpicture}[>=stealth, scale=3]

clip (-2, -0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
draw[<->](-1.5, 0) -- (1.5,0);
draw[<->](0, -1.5) -- (0, 1.5);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);

filldraw[fill=green!20!white, draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] --cycle;
foreach xxtext in {-1,-0.5/-frac{1}{2}, 1}
draw (x cm, 1pt) -- (x cm, -1pt) node [anchor=north] {$xtext$};
foreach y/ytext in {-1,-0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt, y cm) -- (-1pt, y cm) node [anchor=east] {$ytext$};


path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick, orange] (1,0) -- node [right=1pt,fill=white];
{$displaystyle tan alpha color{black} =
frac{{color{red}sin alpha}}{color{blue} cos alpha}$} (t);


end{tikzpicture}


end{document}


This is the result when I compile it:



Result after I compile that code



This is the result shown in the documentationenter image description here:



OS: Ubuntu 18.04 LTS
I have installed Texlive iso on it.










share|improve this question


















  • 1





    On which page did you take that code from? The first code in the TikZ - PGF manual is on the title page, and clearly it is not this. The second code is on page 29, and it is not that long.

    – JouleV
    Mar 11 at 9:37













  • The code specified in the MWE is not correct.

    – Siba Mishra
    Mar 11 at 9:39











  • This is not exactly the first though, this is on page 44. And some of the codes won't even compile and would end up in errors. like the one 118 in Part III.

    – Nauman Afsar
    Mar 11 at 9:40






  • 1





    @NaumanAfsar Suggestion: Please include the source of your profile picture to your profile description.

    – JouleV
    Mar 11 at 9:54






  • 2





    @downvoters: Please don't downvote below a score of -1, even if the question in its current form needs some improvement. A score of -1 is enough to show that the question needs work, anything below that is of no use. Also, if you downvote or vote to close, please leave a comment explaining why you did so, but wait at least 24 hours after asking the OP for improvements to the question before voting to close.

    – Kurt
    Mar 11 at 12:30


















0















In last semester, I started using LaTeX just for assignments and homework but now I wanted to take to the next level.



I started with the tikz library following the pgfmanual. Everytime I try to compile my code I get different result from the documentation, or it won't even compile.



For example this first code I copied it right from the documentation



    documentclass{standalone}
usepackage{tikz}

begin{document}

begin{tikzpicture}[>=stealth, scale=3]

clip (-2, -0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
draw[<->](-1.5, 0) -- (1.5,0);
draw[<->](0, -1.5) -- (0, 1.5);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);

filldraw[fill=green!20!white, draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] --cycle;
foreach xxtext in {-1,-0.5/-frac{1}{2}, 1}
draw (x cm, 1pt) -- (x cm, -1pt) node [anchor=north] {$xtext$};
foreach y/ytext in {-1,-0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt, y cm) -- (-1pt, y cm) node [anchor=east] {$ytext$};


path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick, orange] (1,0) -- node [right=1pt,fill=white];
{$displaystyle tan alpha color{black} =
frac{{color{red}sin alpha}}{color{blue} cos alpha}$} (t);


end{tikzpicture}


end{document}


This is the result when I compile it:



Result after I compile that code



This is the result shown in the documentationenter image description here:



OS: Ubuntu 18.04 LTS
I have installed Texlive iso on it.










share|improve this question


















  • 1





    On which page did you take that code from? The first code in the TikZ - PGF manual is on the title page, and clearly it is not this. The second code is on page 29, and it is not that long.

    – JouleV
    Mar 11 at 9:37













  • The code specified in the MWE is not correct.

    – Siba Mishra
    Mar 11 at 9:39











  • This is not exactly the first though, this is on page 44. And some of the codes won't even compile and would end up in errors. like the one 118 in Part III.

    – Nauman Afsar
    Mar 11 at 9:40






  • 1





    @NaumanAfsar Suggestion: Please include the source of your profile picture to your profile description.

    – JouleV
    Mar 11 at 9:54






  • 2





    @downvoters: Please don't downvote below a score of -1, even if the question in its current form needs some improvement. A score of -1 is enough to show that the question needs work, anything below that is of no use. Also, if you downvote or vote to close, please leave a comment explaining why you did so, but wait at least 24 hours after asking the OP for improvements to the question before voting to close.

    – Kurt
    Mar 11 at 12:30
















0












0








0








In last semester, I started using LaTeX just for assignments and homework but now I wanted to take to the next level.



I started with the tikz library following the pgfmanual. Everytime I try to compile my code I get different result from the documentation, or it won't even compile.



For example this first code I copied it right from the documentation



    documentclass{standalone}
usepackage{tikz}

begin{document}

begin{tikzpicture}[>=stealth, scale=3]

clip (-2, -0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
draw[<->](-1.5, 0) -- (1.5,0);
draw[<->](0, -1.5) -- (0, 1.5);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);

filldraw[fill=green!20!white, draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] --cycle;
foreach xxtext in {-1,-0.5/-frac{1}{2}, 1}
draw (x cm, 1pt) -- (x cm, -1pt) node [anchor=north] {$xtext$};
foreach y/ytext in {-1,-0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt, y cm) -- (-1pt, y cm) node [anchor=east] {$ytext$};


path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick, orange] (1,0) -- node [right=1pt,fill=white];
{$displaystyle tan alpha color{black} =
frac{{color{red}sin alpha}}{color{blue} cos alpha}$} (t);


end{tikzpicture}


end{document}


This is the result when I compile it:



Result after I compile that code



This is the result shown in the documentationenter image description here:



OS: Ubuntu 18.04 LTS
I have installed Texlive iso on it.










share|improve this question














In last semester, I started using LaTeX just for assignments and homework but now I wanted to take to the next level.



I started with the tikz library following the pgfmanual. Everytime I try to compile my code I get different result from the documentation, or it won't even compile.



For example this first code I copied it right from the documentation



    documentclass{standalone}
usepackage{tikz}

begin{document}

begin{tikzpicture}[>=stealth, scale=3]

clip (-2, -0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
draw[<->](-1.5, 0) -- (1.5,0);
draw[<->](0, -1.5) -- (0, 1.5);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);

filldraw[fill=green!20!white, draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] --cycle;
foreach xxtext in {-1,-0.5/-frac{1}{2}, 1}
draw (x cm, 1pt) -- (x cm, -1pt) node [anchor=north] {$xtext$};
foreach y/ytext in {-1,-0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt, y cm) -- (-1pt, y cm) node [anchor=east] {$ytext$};


path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick, orange] (1,0) -- node [right=1pt,fill=white];
{$displaystyle tan alpha color{black} =
frac{{color{red}sin alpha}}{color{blue} cos alpha}$} (t);


end{tikzpicture}


end{document}


This is the result when I compile it:



Result after I compile that code



This is the result shown in the documentationenter image description here:



OS: Ubuntu 18.04 LTS
I have installed Texlive iso on it.







tikz-pgf compilation-error






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 11 at 9:32









Nauman AfsarNauman Afsar

378




378








  • 1





    On which page did you take that code from? The first code in the TikZ - PGF manual is on the title page, and clearly it is not this. The second code is on page 29, and it is not that long.

    – JouleV
    Mar 11 at 9:37













  • The code specified in the MWE is not correct.

    – Siba Mishra
    Mar 11 at 9:39











  • This is not exactly the first though, this is on page 44. And some of the codes won't even compile and would end up in errors. like the one 118 in Part III.

    – Nauman Afsar
    Mar 11 at 9:40






  • 1





    @NaumanAfsar Suggestion: Please include the source of your profile picture to your profile description.

    – JouleV
    Mar 11 at 9:54






  • 2





    @downvoters: Please don't downvote below a score of -1, even if the question in its current form needs some improvement. A score of -1 is enough to show that the question needs work, anything below that is of no use. Also, if you downvote or vote to close, please leave a comment explaining why you did so, but wait at least 24 hours after asking the OP for improvements to the question before voting to close.

    – Kurt
    Mar 11 at 12:30
















  • 1





    On which page did you take that code from? The first code in the TikZ - PGF manual is on the title page, and clearly it is not this. The second code is on page 29, and it is not that long.

    – JouleV
    Mar 11 at 9:37













  • The code specified in the MWE is not correct.

    – Siba Mishra
    Mar 11 at 9:39











  • This is not exactly the first though, this is on page 44. And some of the codes won't even compile and would end up in errors. like the one 118 in Part III.

    – Nauman Afsar
    Mar 11 at 9:40






  • 1





    @NaumanAfsar Suggestion: Please include the source of your profile picture to your profile description.

    – JouleV
    Mar 11 at 9:54






  • 2





    @downvoters: Please don't downvote below a score of -1, even if the question in its current form needs some improvement. A score of -1 is enough to show that the question needs work, anything below that is of no use. Also, if you downvote or vote to close, please leave a comment explaining why you did so, but wait at least 24 hours after asking the OP for improvements to the question before voting to close.

    – Kurt
    Mar 11 at 12:30










1




1





On which page did you take that code from? The first code in the TikZ - PGF manual is on the title page, and clearly it is not this. The second code is on page 29, and it is not that long.

– JouleV
Mar 11 at 9:37







On which page did you take that code from? The first code in the TikZ - PGF manual is on the title page, and clearly it is not this. The second code is on page 29, and it is not that long.

– JouleV
Mar 11 at 9:37















The code specified in the MWE is not correct.

– Siba Mishra
Mar 11 at 9:39





The code specified in the MWE is not correct.

– Siba Mishra
Mar 11 at 9:39













This is not exactly the first though, this is on page 44. And some of the codes won't even compile and would end up in errors. like the one 118 in Part III.

– Nauman Afsar
Mar 11 at 9:40





This is not exactly the first though, this is on page 44. And some of the codes won't even compile and would end up in errors. like the one 118 in Part III.

– Nauman Afsar
Mar 11 at 9:40




1




1





@NaumanAfsar Suggestion: Please include the source of your profile picture to your profile description.

– JouleV
Mar 11 at 9:54





@NaumanAfsar Suggestion: Please include the source of your profile picture to your profile description.

– JouleV
Mar 11 at 9:54




2




2





@downvoters: Please don't downvote below a score of -1, even if the question in its current form needs some improvement. A score of -1 is enough to show that the question needs work, anything below that is of no use. Also, if you downvote or vote to close, please leave a comment explaining why you did so, but wait at least 24 hours after asking the OP for improvements to the question before voting to close.

– Kurt
Mar 11 at 12:30







@downvoters: Please don't downvote below a score of -1, even if the question in its current form needs some improvement. A score of -1 is enough to show that the question needs work, anything below that is of no use. Also, if you downvote or vote to close, please leave a comment explaining why you did so, but wait at least 24 hours after asking the OP for improvements to the question before voting to close.

– Kurt
Mar 11 at 12:30












1 Answer
1






active

oldest

votes


















9














You can't just copy and paste code examples from the manual. You actually have to read the manual to find out how to use the examples. In this case you are missing usetikzlibrary{intersections}.



Here is the relevant part from the tutorial:




enter image description here




documentclass{standalone}
usepackage{tikz}
usetikzlibrary{intersections}
begin{document}
begin{tikzpicture}[scale=3]
clip (-2,-0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] -- cycle;
draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick,blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);
path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick,orange] (1,0) -- node [right=1pt,fill=white]
{$displaystyle tan alpha color{black}=
frac{{color{red}sin alpha}}{color{blue}cos alpha}$} (t);

draw (0,0) -- (t);

foreach x/xtext in {-1, -0.5/-frac{1}{2}, 1}
draw (x cm,1pt) -- (x cm,-1pt) node[anchor=north,fill=white] {$xtext$};
foreach y/ytext in {-1, -0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt,y cm) -- (-1pt,y cm) node[anchor=east,fill=white] {$ytext$};
end{tikzpicture}
end{document}





share|improve this answer



















  • 4





    +1 for the first two sentences!

    – JouleV
    Mar 11 at 9:56











  • I am sorry I just realized I wasn't very clear in my question. I was following the manual bit by bit but as I started getting different results... I got soo annoyed that I just took the whole thing and pasted it.

    – Nauman Afsar
    Mar 11 at 9:57











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478859%2funable-to-compile-basic-tikz-codes-from-pgfmanual%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









9














You can't just copy and paste code examples from the manual. You actually have to read the manual to find out how to use the examples. In this case you are missing usetikzlibrary{intersections}.



Here is the relevant part from the tutorial:




enter image description here




documentclass{standalone}
usepackage{tikz}
usetikzlibrary{intersections}
begin{document}
begin{tikzpicture}[scale=3]
clip (-2,-0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] -- cycle;
draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick,blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);
path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick,orange] (1,0) -- node [right=1pt,fill=white]
{$displaystyle tan alpha color{black}=
frac{{color{red}sin alpha}}{color{blue}cos alpha}$} (t);

draw (0,0) -- (t);

foreach x/xtext in {-1, -0.5/-frac{1}{2}, 1}
draw (x cm,1pt) -- (x cm,-1pt) node[anchor=north,fill=white] {$xtext$};
foreach y/ytext in {-1, -0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt,y cm) -- (-1pt,y cm) node[anchor=east,fill=white] {$ytext$};
end{tikzpicture}
end{document}





share|improve this answer



















  • 4





    +1 for the first two sentences!

    – JouleV
    Mar 11 at 9:56











  • I am sorry I just realized I wasn't very clear in my question. I was following the manual bit by bit but as I started getting different results... I got soo annoyed that I just took the whole thing and pasted it.

    – Nauman Afsar
    Mar 11 at 9:57
















9














You can't just copy and paste code examples from the manual. You actually have to read the manual to find out how to use the examples. In this case you are missing usetikzlibrary{intersections}.



Here is the relevant part from the tutorial:




enter image description here




documentclass{standalone}
usepackage{tikz}
usetikzlibrary{intersections}
begin{document}
begin{tikzpicture}[scale=3]
clip (-2,-0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] -- cycle;
draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick,blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);
path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick,orange] (1,0) -- node [right=1pt,fill=white]
{$displaystyle tan alpha color{black}=
frac{{color{red}sin alpha}}{color{blue}cos alpha}$} (t);

draw (0,0) -- (t);

foreach x/xtext in {-1, -0.5/-frac{1}{2}, 1}
draw (x cm,1pt) -- (x cm,-1pt) node[anchor=north,fill=white] {$xtext$};
foreach y/ytext in {-1, -0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt,y cm) -- (-1pt,y cm) node[anchor=east,fill=white] {$ytext$};
end{tikzpicture}
end{document}





share|improve this answer



















  • 4





    +1 for the first two sentences!

    – JouleV
    Mar 11 at 9:56











  • I am sorry I just realized I wasn't very clear in my question. I was following the manual bit by bit but as I started getting different results... I got soo annoyed that I just took the whole thing and pasted it.

    – Nauman Afsar
    Mar 11 at 9:57














9












9








9







You can't just copy and paste code examples from the manual. You actually have to read the manual to find out how to use the examples. In this case you are missing usetikzlibrary{intersections}.



Here is the relevant part from the tutorial:




enter image description here




documentclass{standalone}
usepackage{tikz}
usetikzlibrary{intersections}
begin{document}
begin{tikzpicture}[scale=3]
clip (-2,-0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] -- cycle;
draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick,blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);
path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick,orange] (1,0) -- node [right=1pt,fill=white]
{$displaystyle tan alpha color{black}=
frac{{color{red}sin alpha}}{color{blue}cos alpha}$} (t);

draw (0,0) -- (t);

foreach x/xtext in {-1, -0.5/-frac{1}{2}, 1}
draw (x cm,1pt) -- (x cm,-1pt) node[anchor=north,fill=white] {$xtext$};
foreach y/ytext in {-1, -0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt,y cm) -- (-1pt,y cm) node[anchor=east,fill=white] {$ytext$};
end{tikzpicture}
end{document}





share|improve this answer













You can't just copy and paste code examples from the manual. You actually have to read the manual to find out how to use the examples. In this case you are missing usetikzlibrary{intersections}.



Here is the relevant part from the tutorial:




enter image description here




documentclass{standalone}
usepackage{tikz}
usetikzlibrary{intersections}
begin{document}
begin{tikzpicture}[scale=3]
clip (-2,-0.2) rectangle (2,0.8);
draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] -- cycle;
draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
draw (0,0) circle [radius=1cm];

draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$sin alpha$} (30:1cm |- x axis);
draw[very thick,blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$cos alpha$} (0,0);
path [name path=upward line] (1,0) -- (1,1);
path [name path=sloped line] (0,0) -- (30:1.5cm);
draw [name intersections={of=upward line and sloped line, by=t}]
[very thick,orange] (1,0) -- node [right=1pt,fill=white]
{$displaystyle tan alpha color{black}=
frac{{color{red}sin alpha}}{color{blue}cos alpha}$} (t);

draw (0,0) -- (t);

foreach x/xtext in {-1, -0.5/-frac{1}{2}, 1}
draw (x cm,1pt) -- (x cm,-1pt) node[anchor=north,fill=white] {$xtext$};
foreach y/ytext in {-1, -0.5/-frac{1}{2}, 0.5/frac{1}{2}, 1}
draw (1pt,y cm) -- (-1pt,y cm) node[anchor=east,fill=white] {$ytext$};
end{tikzpicture}
end{document}






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 11 at 9:54









Henri MenkeHenri Menke

77k8168283




77k8168283








  • 4





    +1 for the first two sentences!

    – JouleV
    Mar 11 at 9:56











  • I am sorry I just realized I wasn't very clear in my question. I was following the manual bit by bit but as I started getting different results... I got soo annoyed that I just took the whole thing and pasted it.

    – Nauman Afsar
    Mar 11 at 9:57














  • 4





    +1 for the first two sentences!

    – JouleV
    Mar 11 at 9:56











  • I am sorry I just realized I wasn't very clear in my question. I was following the manual bit by bit but as I started getting different results... I got soo annoyed that I just took the whole thing and pasted it.

    – Nauman Afsar
    Mar 11 at 9:57








4




4





+1 for the first two sentences!

– JouleV
Mar 11 at 9:56





+1 for the first two sentences!

– JouleV
Mar 11 at 9:56













I am sorry I just realized I wasn't very clear in my question. I was following the manual bit by bit but as I started getting different results... I got soo annoyed that I just took the whole thing and pasted it.

– Nauman Afsar
Mar 11 at 9:57





I am sorry I just realized I wasn't very clear in my question. I was following the manual bit by bit but as I started getting different results... I got soo annoyed that I just took the whole thing and pasted it.

– Nauman Afsar
Mar 11 at 9:57


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f478859%2funable-to-compile-basic-tikz-codes-from-pgfmanual%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?