我不想使用独立版,因为我想在 tikzpicture 上方添加一些文本。因此,我尝试使用 article 并调整边距以适合我的 tikzpicture。在此示例中,tikzpicture 宽度为 6 厘米,因此我想将分页器宽度调整为 6 厘米,并将边距调整为 0。
\documentclass{article}
\usepackage{tikz}
\usepackage[pass,
paperwidth=6cm,paperheight=12cm,
margin=0cm,
]{geometry}
\usetikzlibrary{calc}
\usetikzlibrary{shapes,calc,fit,backgrounds,intersections}
\begin{document}
$2\sqrt{r1*r2} + 2\sqrt{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};
}
\ifnum\value{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}
但以上仍然没有改变我的纸张宽度!
答案1
几何包文档说:
pass
verbose
禁用除和 之外的所有几何选项和计算showframe
。它与顺序无关,可用于检查 documentclass 的页面布局、其他包和手动设置,而无需geometry
。
删除该pass
选项将geometry
得到:
我稍微调整了高度和宽度。
\usepackage[
paperwidth=6.5cm,paperheight=12.5cm,
margin=0cm,
]{geometry}
完整的 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}
$2\sqrt{r1*r2} + 2\sqrt{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};
}
\ifnum\value{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}