我想优化用于绘图的 latex 代码(即使其在 1 周后更易于阅读/更新),因此我尝试使用一些宏来实现这一点。现在,我知道下面的例子很愚蠢,但你能帮我一下吗 - 我真的不明白,为什么我不能用我的宏画一些正方形。
所以基本上我想用这样的东西
\newcommand*\myPatternsB{
\squareNVSE{0.00}{77.99}
\squareNVSE{6.01}{77.99}
\squareNVSE{12.02}{77.99}
}
而不是这个
\newcommand*\myPatternsA{
\draw [draw=gray, very thin] ( 0.00mm, 77.99mm) -| ( 6.00mm, 71.99mm) -| ( 0.00mm, 77.99mm);
\draw [draw=gray, very thin] ( 6.01mm, 77.99mm) -| ( 12.01mm, 71.99mm) -| ( 6.01mm, 77.99mm);
\draw [draw=gray, very thin] ( 12.02mm, 77.99mm) -| ( 18.02mm, 71.99mm) -| ( 12.02mm, 77.99mm);
}
方形宏如下所示
\newcommand*\squareNVSE[2]{
\draw [draw=gray, very thin]
( #1 mm, #2 mm)
-| ( #1 + 6.00mm, #2 - 6.00mm)
-| ( #1 mm, #2 mm);
% what I want this macro/function to do
%\draw [draw=gray, very thin]
% ( 0.00mm, 77.99mm)
% -| ( 6.00mm, 71.99mm)
% -| ( 0.00mm, 77.99mm);
}
我正在使用以下代码
\documentclass[a4paper,10pt,fleqn]{article}
\usepackage{tikz}
\newcommand*\squareNVSE[2]{
\draw [draw=gray, very thin]
( #1 mm, #2 mm)
-| ( #1 + 6.00mm, #2 - 6.00mm)
-| ( #1 mm, #2 mm);
% what I want this macro/function to do
%\draw [draw=gray, very thin]
% ( 0.00mm, 77.99mm)
% -| ( 6.00mm, 71.99mm)
% -| ( 0.00mm, 77.99mm);
}
\newcommand*\drawing{
\draw ( 12.10mm, 81.39mm) %a8
-- ( 1.50mm, 81.39mm) %a9
-- ( 1.50mm, 77.99mm) %a10
-- ( 0.00mm, 77.99mm); %a11
\node [anchor=north] at ( 12.10mm, 81.39mm) {\tiny a8};
\node [anchor=south] at ( 1.50mm, 81.39mm) {\tiny a9};
\node [anchor=south west] at ( 1.50mm, 77.99mm) {\tiny a10};
\node [anchor=south] at ( 0.00mm, 77.99mm) {\tiny a11};
}
\newcommand*\myPatternsA{
\draw [draw=gray, very thin] ( 0.00mm, 77.99mm) -| ( 6.00mm, 71.99mm) -| ( 0.00mm, 77.99mm);
\draw [draw=gray, very thin] ( 6.01mm, 77.99mm) -| ( 12.01mm, 71.99mm) -| ( 6.01mm, 77.99mm);
\draw [draw=gray, very thin] ( 12.02mm, 77.99mm) -| ( 18.02mm, 71.99mm) -| ( 12.02mm, 77.99mm);
}
\newcommand*\myPatternsB{
\squareNVSE{0.00}{77.99}
\squareNVSE{6.01}{77.99}
\squareNVSE{12.02}{77.99}
}
\begin{document}
\begin{figure*}
\begin{tikzpicture}[xscale=2, yscale=2]
\myPatternsA
\drawing
\end{tikzpicture}
\end{figure*}
\begin{figure*}[tH]
\begin{tikzpicture}[xscale=2, yscale=2]
\myPatternsB
\drawing
\end{tikzpicture}
\end{figure*}
\end{document}
我正在使用“pdfTeX,版本 3.1415926-2.5-1.40.14(MiKTeX 2.9 64 位)(预加载格式=pdflatex 2014.8.25)” - 我知道它有点旧,但是仍然...
我正在使用 notepad++ 执行以下操作
npp_save
cmd /c cd /d "$(CURRENT_DIRECTORY)" && pdflatex.exe -shell-escape "$(FILE_NAME)"
cmd /c cd /d "$(CURRENT_DIRECTORY)" && makeindex "$(FILE_NAME)".idx
cmd /c cd /d "$(CURRENT_DIRECTORY)" && pdflatex.exe -shell-escape "$(FILE_NAME)"
cmd /c cd /d "$(CURRENT_DIRECTORY)" && pdflatex.exe -shell-escape "$(FILE_NAME)"
"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" "$(CURRENT_DIRECTORY)\$(NAME_PART).pdf"
答案1
(对于标记为“已解决”的问题,即有一个可接受的答案)
作为懒惰的松鼠在评论中指出,( #1 + 6.00mm, #2 - 6.00mm)
你忘记了两个单位mm
,这使得应用了默认单位cm
,最终使得绘图比预期高得多。