如您所见,圆弧对于页面来说太大了。因此,我尝试使用 缩放图像[scale=0.5]
。
这对于直线段非常有效。然而,TikZ 不会缩放圆弧,而是改变其大小,而是让圆弧的中心彼此更接近。
这是第一张图片的 MWE。
\documentclass[a4paper]{article}
\usepackage{tikz}
\tikzset{
pics/carc/.style args={#1:#2:#3}{
code={
\draw[pic actions] (#1:#3) arc(#1:#2:#3);
}
}
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[scale=0.5]
\tikzstyle{disk} = [draw, thick, circle,fill=none]
\tikzstyle{center} = [draw,shape=rectangle,fill=blue]
\tikzstyle{intersection} = [draw, circle ,fill=darkgray, inner sep=0.8mm]
\node at (-6,0) {$A$};
\node at (1,0) {$B$};
\node at (-2,-6) {$C$};
\draw[thick] (-8,0) pic{carc=-100:50:60mm};
\draw[thick] (2,0) pic{carc=130:300:60mm};
\draw[thick,red] (3.2,0) pic{carc=130:300:60mm};
\draw[thick] (-2,-14) pic{carc=30:150:100mm};
\draw[dashed] (-3,6)--(-3, -6);
\draw[red] (-2.8,6)--(-2.8, -6);
\draw[blue] (-2.2,6)--(-2.2, -6);
\end{tikzpicture}
\caption{Zoomed in}
\label{fig:zoom}
\end{figure}
\end{document}
我该怎么做才能缩放弧线?
答案1
您可以使用transform shape
,请参阅 TikZ 和 PGF 手册 (针对版本 3.0.1a) 第 17.7 节。
顺便说一下,也请看一下这篇文章:应该使用 \tikzset 还是 \tikzstyle 来定义 TikZ 样式?。
\documentclass[a4paper]{article}
\usepackage{tikz}
\tikzset{
pics/carc/.style args={#1:#2:#3}{
code={
\draw[pic actions] (#1:#3) arc(#1:#2:#3);
}
}
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
scale=0.5,
transform shape,
disk/.style={draw, thick, circle, fill=none},
center/.style={draw,shape=rectangle,fill=blue},
intersection/.style={draw, circle, fill=darkgray, inner sep=0.8mm}
]
\node at (-6,0) {$A$};
\node at (1,0) {$B$};
\node at (-2,-6) {$C$};
\draw[thick] (-8,0) pic{carc=-100:50:60mm};
\draw[thick] (2,0) pic{carc=130:300:60mm};
\draw[thick,red] (3.2,0) pic{carc=130:300:60mm};
\draw[thick] (-2,-14) pic{carc=30:150:100mm};
\draw[dashed] (-3,6) -- (-3,-6);
\draw[red] (-2.8,6) -- (-2.8,-6);
\draw[blue] (-2.2,6) -- (-2.2,-6);
\end{tikzpicture}
\caption{Zoomed in\label{fig:zoom}}
\end{figure}
\end{document}
或者,如果您不想更改节点文本大小,请仅将其添加到带有图片的绘图中:
\documentclass[a4paper]{article}
\usepackage{tikz}
\tikzset{
pics/carc/.style args={#1:#2:#3}{
code={
\draw[pic actions] (#1:#3) arc(#1:#2:#3);
}
}
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[
scale=0.5,
disk/.style={draw, thick, circle, fill=none},
center/.style={draw,shape=rectangle,fill=blue},
intersection/.style={draw, circle, fill=darkgray, inner sep=0.8mm}
]
\node at (-6,0) {$A$};
\node at (1,0) {$B$};
\node at (-2,-6) {$C$};
\draw[thick,transform shape,
] (-8,0) pic{carc=-100:50:60mm};
\draw[thick,transform shape] (2,0) pic{carc=130:300:60mm};
\draw[thick,red,transform shape] (3.2,0) pic{carc=130:300:60mm};
\draw[thick,transform shape] (-2,-14) pic{carc=30:150:100mm};
\draw[dashed] (-3,6) -- (-3,-6);
\draw[red] (-2.8,6) -- (-2.8,-6);
\draw[blue] (-2.2,6) -- (-2.2,-6);
\end{tikzpicture}
\caption{Zoomed in\label{fig:zoom}}
\end{figure}
\end{document}
答案2
图片缩放不正确。您应该在 carc 定义中单独设置 scale=0.5
\documentclass[a4paper]{article}
\usepackage{tikz}
\tikzset{
pics/carc/.style args={#1:#2:#3}{
code={
\draw[pic actions,scale=0.5] (#1:#3) arc(#1:#2:#3);
}
}
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[scale=0.5]
\tikzstyle{disk} = [draw, thick, circle,fill=none]
\tikzstyle{center} = [draw,shape=rectangle,fill=blue]
\tikzstyle{intersection} = [draw, circle ,fill=darkgray, inner sep=0.8mm]
\node at (-6,0) {$A$};
\node at (1,0) {$B$};
\node at (-2,-6) {$C$};
\draw[thick] (-8,0) pic{carc=-100:50:60mm};
\draw[thick] (2,0) pic{carc=130:300:60mm};
\draw[thick,red] (3.2,0) pic{carc=130:300:60mm};
\draw[thick] (-2,-14) pic{carc=30:150:100mm};
\draw[dashed] (-3,6)--(-3, -6);
\draw[red] (-2.8,6)--(-2.8, -6);
\draw[blue] (-2.2,6)--(-2.2, -6);
\end{tikzpicture}
\caption{Zoomed in}
\label{fig:zoom}
\end{figure}
\end{document}