Change paper size to match TikZ picture dimension












2














I do not want to use standalone since I want to add some text above of the tikzpicture.
So I try to use article and adjust the margin to fit my tikzpicture. In this example, the tikzpicture is 6cm width, so I want to adjust the pager width to 6cm and margin to 0.



documentclass{article}
usepackage{tikz}
usepackage[pass,
paperwidth=6cm,paperheight=12cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}


But above still not change my paper width!



enter image description here










share|improve this question






















  • You could add the text in form of a node. Then you could use the standalone class. And at any rate I would suggest to add the debug stuff with the overlay option such that it does not affect the bounding box.
    – marmot
    Dec 9 at 17:00










  • @marmot Thanks, what's the different between pgfinterruptboundingbox and scope overly option?
    – lucky1928
    Dec 9 at 18:51










  • Nothing AFAIK at the level of TikZ. However, pgfinterruptboundingbox is a pgf environment, and can hence also be used at the pgf level. My comment concerned the F1 label and so on, which are outside the pgfinterruptboundingbox and can influence the bounding box.
    – marmot
    Dec 9 at 18:53


















2














I do not want to use standalone since I want to add some text above of the tikzpicture.
So I try to use article and adjust the margin to fit my tikzpicture. In this example, the tikzpicture is 6cm width, so I want to adjust the pager width to 6cm and margin to 0.



documentclass{article}
usepackage{tikz}
usepackage[pass,
paperwidth=6cm,paperheight=12cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}


But above still not change my paper width!



enter image description here










share|improve this question






















  • You could add the text in form of a node. Then you could use the standalone class. And at any rate I would suggest to add the debug stuff with the overlay option such that it does not affect the bounding box.
    – marmot
    Dec 9 at 17:00










  • @marmot Thanks, what's the different between pgfinterruptboundingbox and scope overly option?
    – lucky1928
    Dec 9 at 18:51










  • Nothing AFAIK at the level of TikZ. However, pgfinterruptboundingbox is a pgf environment, and can hence also be used at the pgf level. My comment concerned the F1 label and so on, which are outside the pgfinterruptboundingbox and can influence the bounding box.
    – marmot
    Dec 9 at 18:53
















2












2








2







I do not want to use standalone since I want to add some text above of the tikzpicture.
So I try to use article and adjust the margin to fit my tikzpicture. In this example, the tikzpicture is 6cm width, so I want to adjust the pager width to 6cm and margin to 0.



documentclass{article}
usepackage{tikz}
usepackage[pass,
paperwidth=6cm,paperheight=12cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}


But above still not change my paper width!



enter image description here










share|improve this question













I do not want to use standalone since I want to add some text above of the tikzpicture.
So I try to use article and adjust the margin to fit my tikzpicture. In this example, the tikzpicture is 6cm width, so I want to adjust the pager width to 6cm and margin to 0.



documentclass{article}
usepackage{tikz}
usepackage[pass,
paperwidth=6cm,paperheight=12cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}


But above still not change my paper width!



enter image description here







tikz-pgf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 9 at 16:45









lucky1928

1,1971716




1,1971716












  • You could add the text in form of a node. Then you could use the standalone class. And at any rate I would suggest to add the debug stuff with the overlay option such that it does not affect the bounding box.
    – marmot
    Dec 9 at 17:00










  • @marmot Thanks, what's the different between pgfinterruptboundingbox and scope overly option?
    – lucky1928
    Dec 9 at 18:51










  • Nothing AFAIK at the level of TikZ. However, pgfinterruptboundingbox is a pgf environment, and can hence also be used at the pgf level. My comment concerned the F1 label and so on, which are outside the pgfinterruptboundingbox and can influence the bounding box.
    – marmot
    Dec 9 at 18:53




















  • You could add the text in form of a node. Then you could use the standalone class. And at any rate I would suggest to add the debug stuff with the overlay option such that it does not affect the bounding box.
    – marmot
    Dec 9 at 17:00










  • @marmot Thanks, what's the different between pgfinterruptboundingbox and scope overly option?
    – lucky1928
    Dec 9 at 18:51










  • Nothing AFAIK at the level of TikZ. However, pgfinterruptboundingbox is a pgf environment, and can hence also be used at the pgf level. My comment concerned the F1 label and so on, which are outside the pgfinterruptboundingbox and can influence the bounding box.
    – marmot
    Dec 9 at 18:53


















You could add the text in form of a node. Then you could use the standalone class. And at any rate I would suggest to add the debug stuff with the overlay option such that it does not affect the bounding box.
– marmot
Dec 9 at 17:00




You could add the text in form of a node. Then you could use the standalone class. And at any rate I would suggest to add the debug stuff with the overlay option such that it does not affect the bounding box.
– marmot
Dec 9 at 17:00












@marmot Thanks, what's the different between pgfinterruptboundingbox and scope overly option?
– lucky1928
Dec 9 at 18:51




@marmot Thanks, what's the different between pgfinterruptboundingbox and scope overly option?
– lucky1928
Dec 9 at 18:51












Nothing AFAIK at the level of TikZ. However, pgfinterruptboundingbox is a pgf environment, and can hence also be used at the pgf level. My comment concerned the F1 label and so on, which are outside the pgfinterruptboundingbox and can influence the bounding box.
– marmot
Dec 9 at 18:53






Nothing AFAIK at the level of TikZ. However, pgfinterruptboundingbox is a pgf environment, and can hence also be used at the pgf level. My comment concerned the F1 label and so on, which are outside the pgfinterruptboundingbox and can influence the bounding box.
– marmot
Dec 9 at 18:53












1 Answer
1






active

oldest

votes


















3














Geometry package documentation says:




pass disables all of the geometry options and calculations except verbose
and showframe. It is order-independent and can be used for checking
out the page layout of the documentclass, other packages and manual
settings without geometry.




Removing the pass option in geometry gives:



enter image description here



I have adjusted the height and width slightly.



usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}


The complete MWE:



documentclass{article}
usepackage{tikz}
usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}





share|improve this answer























  • Great, thanks, one more question: the margin is 0 but why the left side still some space there?
    – lucky1928
    Dec 9 at 17:15










  • @lucky1928 I think it's because of P1 and P2.
    – nidhin
    Dec 9 at 17:30










  • Exactly! after move it to right, it's perfect now! thanks again!
    – lucky1928
    Dec 9 at 17:37










  • @lucky1928 --- a hint: if you surround your "debug" code with begin{scope}[overlay] ... end{scope} it will not affect the bounding box, i.e., the size of the final image.
    – Rmano
    Dec 9 at 18:13











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%2f463977%2fchange-paper-size-to-match-tikz-picture-dimension%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









3














Geometry package documentation says:




pass disables all of the geometry options and calculations except verbose
and showframe. It is order-independent and can be used for checking
out the page layout of the documentclass, other packages and manual
settings without geometry.




Removing the pass option in geometry gives:



enter image description here



I have adjusted the height and width slightly.



usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}


The complete MWE:



documentclass{article}
usepackage{tikz}
usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}





share|improve this answer























  • Great, thanks, one more question: the margin is 0 but why the left side still some space there?
    – lucky1928
    Dec 9 at 17:15










  • @lucky1928 I think it's because of P1 and P2.
    – nidhin
    Dec 9 at 17:30










  • Exactly! after move it to right, it's perfect now! thanks again!
    – lucky1928
    Dec 9 at 17:37










  • @lucky1928 --- a hint: if you surround your "debug" code with begin{scope}[overlay] ... end{scope} it will not affect the bounding box, i.e., the size of the final image.
    – Rmano
    Dec 9 at 18:13
















3














Geometry package documentation says:




pass disables all of the geometry options and calculations except verbose
and showframe. It is order-independent and can be used for checking
out the page layout of the documentclass, other packages and manual
settings without geometry.




Removing the pass option in geometry gives:



enter image description here



I have adjusted the height and width slightly.



usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}


The complete MWE:



documentclass{article}
usepackage{tikz}
usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}





share|improve this answer























  • Great, thanks, one more question: the margin is 0 but why the left side still some space there?
    – lucky1928
    Dec 9 at 17:15










  • @lucky1928 I think it's because of P1 and P2.
    – nidhin
    Dec 9 at 17:30










  • Exactly! after move it to right, it's perfect now! thanks again!
    – lucky1928
    Dec 9 at 17:37










  • @lucky1928 --- a hint: if you surround your "debug" code with begin{scope}[overlay] ... end{scope} it will not affect the bounding box, i.e., the size of the final image.
    – Rmano
    Dec 9 at 18:13














3












3








3






Geometry package documentation says:




pass disables all of the geometry options and calculations except verbose
and showframe. It is order-independent and can be used for checking
out the page layout of the documentclass, other packages and manual
settings without geometry.




Removing the pass option in geometry gives:



enter image description here



I have adjusted the height and width slightly.



usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}


The complete MWE:



documentclass{article}
usepackage{tikz}
usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}





share|improve this answer














Geometry package documentation says:




pass disables all of the geometry options and calculations except verbose
and showframe. It is order-independent and can be used for checking
out the page layout of the documentclass, other packages and manual
settings without geometry.




Removing the pass option in geometry gives:



enter image description here



I have adjusted the height and width slightly.



usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}


The complete MWE:



documentclass{article}
usepackage{tikz}
usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}
usetikzlibrary{calc}
usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
begin{document}
$2sqrt{r1*r2} + 2sqrt{r1(r2+r3-r1)}$\
begin{tikzpicture}
tikzset{>=latex}
newcommand{ann}[5] {
draw[|<->|,line width=0.5pt,red,#1] ([yshift=#2]#3) -- node[above] {#5} ([yshift=#2]#4);
}
newcounter{debug}setcounter{debug}{1} %debug code: 1-debug,0-release
[background rectangle/.style={fill=olive!30}, show background rectangle]
coordinate (O1) at (0,0);
begin{pgfinterruptboundingbox}
path[name path=C1] (O1) circle (5);
path[name path=L1] (-1,0)--(-1,5);
path [name intersections={of= L1 and C1,by=O2}];

path[name path=C2] (O2) circle (3.5);
path (O2) --++(2.5,0) coordinate (Q2);
path[name path=L2] (Q2)--++(0,4.5);
path [name intersections={of= L2 and C2,by=O3}];
end{pgfinterruptboundingbox}

path (O1) --++(-180:3) coordinate (P1);
path (O2) --++(-180:2) coordinate (P2);
path (O3) --++(0:1.5) coordinate (P3);
coordinate (P7) at (O1 |- O2);
coordinate (P8) at (O2 -| O3);
ann{0}{P1}{O1}{r1};
ann{0}{P2}{O2}{r2};
ann{0}{P3}{O3}{r3};
node[draw,circle,minimum size=6cm,inner sep=0] (Q1) at (O1) {};
node[draw,circle,minimum size=4cm,inner sep=0] (Q2) at (O2) {};
node[draw,circle,minimum size=3cm,inner sep=0] (Q3) at (O3) {};
node[draw,fit=(Q1)(O2)(Q3),inner sep=0] (Q4) {};
foreach i in {O1,O2,O3} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
ifnumvalue{debug}=1 %debug code
draw[red!50] (O1) -- (O2) -- (O3)
(O1) |- (O2) (O2) -| (O3)
;

foreach i in {P1,P2,P3,P7,P8} {
fill[shift=(i),red!50] (0,0) circle(2pt) node[below,shift=(i)] {i};
}
draw ([xshift=-2mm]P7) |- ([yshift=-2mm]P7);
draw ([xshift=-2mm]P8) |- ([yshift=2mm]P8);
fi
end{tikzpicture}
end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 9 at 17:04

























answered Dec 9 at 16:56









nidhin

3,342927




3,342927












  • Great, thanks, one more question: the margin is 0 but why the left side still some space there?
    – lucky1928
    Dec 9 at 17:15










  • @lucky1928 I think it's because of P1 and P2.
    – nidhin
    Dec 9 at 17:30










  • Exactly! after move it to right, it's perfect now! thanks again!
    – lucky1928
    Dec 9 at 17:37










  • @lucky1928 --- a hint: if you surround your "debug" code with begin{scope}[overlay] ... end{scope} it will not affect the bounding box, i.e., the size of the final image.
    – Rmano
    Dec 9 at 18:13


















  • Great, thanks, one more question: the margin is 0 but why the left side still some space there?
    – lucky1928
    Dec 9 at 17:15










  • @lucky1928 I think it's because of P1 and P2.
    – nidhin
    Dec 9 at 17:30










  • Exactly! after move it to right, it's perfect now! thanks again!
    – lucky1928
    Dec 9 at 17:37










  • @lucky1928 --- a hint: if you surround your "debug" code with begin{scope}[overlay] ... end{scope} it will not affect the bounding box, i.e., the size of the final image.
    – Rmano
    Dec 9 at 18:13
















Great, thanks, one more question: the margin is 0 but why the left side still some space there?
– lucky1928
Dec 9 at 17:15




Great, thanks, one more question: the margin is 0 but why the left side still some space there?
– lucky1928
Dec 9 at 17:15












@lucky1928 I think it's because of P1 and P2.
– nidhin
Dec 9 at 17:30




@lucky1928 I think it's because of P1 and P2.
– nidhin
Dec 9 at 17:30












Exactly! after move it to right, it's perfect now! thanks again!
– lucky1928
Dec 9 at 17:37




Exactly! after move it to right, it's perfect now! thanks again!
– lucky1928
Dec 9 at 17:37












@lucky1928 --- a hint: if you surround your "debug" code with begin{scope}[overlay] ... end{scope} it will not affect the bounding box, i.e., the size of the final image.
– Rmano
Dec 9 at 18:13




@lucky1928 --- a hint: if you surround your "debug" code with begin{scope}[overlay] ... end{scope} it will not affect the bounding box, i.e., the size of the final image.
– Rmano
Dec 9 at 18:13


















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f463977%2fchange-paper-size-to-match-tikz-picture-dimension%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

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?