我正在寻找一种解决方案来排除一些 TikZ 命令的scale
影响。该scale
选项合并tikzpicture
并缩放为一个整体,我正在寻找一种方法来从该合并中删除某些命令。
一个例子是直角框。我倾向于绘制很多包含直角标记的图形,并且我需要它无论比例如何都保持其恒定的尺寸,因为在缩小的情况下它几乎消失。我知道可以使用范围来完成,但就我而言这是不可行的,因为我正在使用不同程序中的脚本来缩放整个 TikZ 绘图。
所以简单地说,我想知道是否有任何类型的环境可以为通用scale
选项排除某些 TikZ 命令。
\documentclass[tikz,border=12pt]{standalone}
\usepackage{stix, tikz, tkz-euclide}
\usetikzlibrary{angles, calc, quotes, arrows, arrows.meta}
\usetkzobj{all}
\begin{document}
%% The scale command
\begin{tikzpicture}[scale=0.3]
\begin{scope}[thick, >={Stealth[scale=1.2]}]
\coordinate[label=below left:\textcolor{red}{$O$}] (o) at (0,0);
\coordinate (a) at (4,0);
\coordinate [label=below :\textcolor{red}{$A$}](aa) at ({0.87*4},0);
\coordinate (c) at (0,4);
\coordinate [label= left:\textcolor{red}{$C$}](cc) at (0,{0.87*4});
\path (o)--(58:4) coordinate (b);
\coordinate [label=above left:\textcolor{red}{$B$}](bb) at (58:{0.87*4});
%% The Right angel command
\tkzMarkRightAngle[size=0.4,opacity=1,color=red](a,o,c);
\path [decorate, decoration={markings, mark=at position 0.87 with {\draw[thick] (0pt,-2pt)--(0pt,2pt);}}] (o)--(a);
\path [decorate, decoration={markings, mark=at position 0.87 with {\draw[thick] (0pt,-2pt)--(0pt,2pt);}}] (o)--(b);
\path [decorate, decoration={markings, mark=at position 0.87 with {\draw[thick] (0pt,-2pt)--(0pt,2pt);}}] (o)--(c);
\draw[<->] (a)--(o)--(c);
\draw[->] (o)--(b);
\end{scope}
\end{tikzpicture}
\end{document}
在上面的绘图中,scale
是 0.3。有时我会绘制具有实际尺寸的几何结构,然后将其缩小。
答案1
一个想法。在你的绘图中,你可以恢复正在使用的比例因子(如在 TikZ 环境中访问比例选项) 并使用该值调整标记的大小,以便它再次以相同的倍数“放大”,从而保持相同的表观尺寸。
例如:
\documentclass[tikz,border=12pt]{standalone}
\usepackage{stix, tikz, tkz-euclide}
\usetikzlibrary{angles, calc, quotes, arrows, arrows.meta}
\usetkzobj{all}
\begin{document}
%% The scale command
\begin{tikzpicture}[scale=1.0]
\begin{scope}[thick, >={Stealth[scale=1.2]}]
\coordinate[label=below left:\textcolor{red}{$O$}] (o) at (0,0);
\coordinate (a) at (4,0);
\coordinate [label=below :\textcolor{red}{$A$}](aa) at ({0.87*4},0);
\coordinate (c) at (0,4);
\coordinate [label= left:\textcolor{red}{$C$}](cc) at (0,{0.87*4});
\path (o)--(58:4) coordinate (b);
\coordinate [label=above left:\textcolor{red}{$B$}](bb) at (58:{0.87*4});
%% The Right angel command
\pgfgettransformentries{\mya}{\myb}{\myc}{\myd}{\mys}{\myt}
\pgfmathsetmacro{\grow}{1/\mya}
\tkzMarkRightAngle[size=0.4*\grow, opacity=1,color=red](a,o,c);
\path [decorate, decoration={markings, mark=at position 0.87 with {\draw[thick] (0pt,-2pt)--(0pt,2pt);}}] (o)--(a);
\path [decorate, decoration={markings, mark=at position 0.87 with {\draw[thick] (0pt,-2pt)--(0pt,2pt);}}] (o)--(b);
\path [decorate, decoration={markings, mark=at position 0.87 with {\draw[thick] (0pt,-2pt)--(0pt,2pt);}}] (o)--(c);
\draw[<->] (a)--(o)--(c);
\draw[->] (o)--(b);
\end{scope}
\end{tikzpicture}
\end{document}
比较外圈尺度分别为1、0.6、0.3时的结果: