我不擅长用 Ti 画画钾Z,而且需要很长时间,所以我决定采用一种新方法。当我使用 Illustrator 和 Inkscape 时,我喜欢从网格开始;就像方格纸一样。所以现在我这样做(如下),所以我有一个巨大的画布,我所要做的就是连接点(顶点)。然后当我完成后,我只需%
在前面粘贴一个\draw (0,0) grid (100,100);
,网格就消失了。
我现在想要的是,为每个节点标注相应的坐标(是的,全部坐标),这样我就可以快速勾勒出轮廓,而不必浪费太多时间猜测和重新编译。在每个顶点或相邻空间中都应该没问题,但如果可能的话,不要太过碍事(也许隐藏在角落中,使用离散色调或半透明;一些实用的东西)。如果我可以通过编程和循环来解决这个问题,而不是手动输入每个坐标,那显然是理想的。无论如何,这是 MWE:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt]{standalone}
\usepackage{tikz}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}
\draw (0,0) grid (100,100);
\end{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
答案1
对这个很好的答案但我不确定这有多大帮助。如果没有帮助,或者 LoopSpace 想要写一个答案,我很乐意删除它。
\documentclass[tikz,border=3.14mm]{standalone}
\makeatletter% from https://tex.stackexchange.com/a/39698/121799
\def\grd@save@target#1{%
\def\grd@target{#1}}
\def\grd@save@start#1{%
\def\grd@start{#1}}
\tikzset{
labeled grid/.style={
to path={%
\pgfextra{%
\edef\grd@@target{(\tikztotarget)}%
\tikz@scan@one@point\grd@save@target\grd@@target\relax
\edef\grd@@start{(\tikztostart)}%
\tikz@scan@one@point\grd@save@start\grd@@start\relax
\draw[minor help lines] (\tikztostart) grid (\tikztotarget);
\draw[major help lines] (\tikztostart) grid (\tikztotarget);
\grd@start
\pgfmathsetmacro{\grd@xa}{\the\pgf@x/1cm}
\pgfmathsetmacro{\grd@ya}{\the\pgf@y/1cm}
\grd@target
\pgfmathsetmacro{\grd@xb}{\the\pgf@x/1cm}
\pgfmathsetmacro{\grd@yb}{\the\pgf@y/1cm}
\pgfmathsetmacro{\grd@xc}{\grd@xa + \pgfkeysvalueof{/tikz/grid with coordinates/major step}}
\pgfmathsetmacro{\grd@yc}{\grd@ya + \pgfkeysvalueof{/tikz/grid with coordinates/major step}}
\foreach \x in {\grd@xa,\grd@xc,...,\grd@xb}
\node[anchor=north] at (\x,\grd@ya) {\pgfmathprintnumber{\x}};
\foreach \y in {\grd@ya,\grd@yc,...,\grd@yb}
\node[anchor=east] at (\grd@xa,\y) {\pgfmathprintnumber{\y}};
\path foreach \x in {\grd@xa,\grd@xc,...,\grd@xb}
{foreach \y in {\grd@ya,\grd@yc,...,\grd@yb}
{ (\x,\y) node[grid with coordinates/grid label] {$(\pgfmathprintnumber{\x},\pgfmathprintnumber{\x})$}}};
}
}
},
minor help lines/.style={
help lines,
step=\pgfkeysvalueof{/tikz/grid with coordinates/minor step},
draw=none
},
major help lines/.style={
help lines,
line width=\pgfkeysvalueof{/tikz/grid with coordinates/major line width},
step=\pgfkeysvalueof{/tikz/grid with coordinates/major step}
},
grid with coordinates/.cd,
minor step/.initial=.2,
major step/.initial=1,
major line width/.initial=2pt,
grid label/.style={below left,scale=0.5,opacity=0.5}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw (0,0) to[labeled grid] (10,10);
\end{tikzpicture}
\end{document}