提问于:
浏览数:
1780
tikz画的图放大后本该重合的线段出现了少量偏移,是否是因为tikz精度的问题,未测试添加对`fpu`的支持后能否解决该问题。
![](https://pics.latexstudio.net/data/images/201911/d89b9e610e7a13b.png)
![](https://pics.latexstudio.net/data/images/201911/deac59bd6347708.png)
`tikz.tex`
```tex
\documentclass[tikz, border=4mm]{standalone}
\usepackage{dnnplot}
\usetikzlibrary{positioning}
\tikzset{
base/.style n args={5}{block={scale=.5, x=#2cm, y=#3cm, z=#4cm, #5}, fill=#1, fill opacity=.5},
Input/.style={base={teal}{.2}{5}{5}{grid={(1,5,5)},#1}},
Kernel/.style={base={cyan}{.2}{3}{3}{grid={(1,3,3)},#1}, fill opacity=1},
Output/.style={base={teal}{.2}{3}{3}{grid={(1,3,3)},#1}},
Cell/.style={base={teal}{.2}{1}{1}{#1}},
}
\begin{document}
\begin{tikzpicture}
\pgfdeclarelayer{background block}
\pgfsetlayers{background block, main}
\newcommand{\back}[1]{\begin{pgfonlayer}{background block}#1\end{pgfonlayer}}
\newlength\xsep \xsep=3.5cm
\newlength\ysep \ysep=3.5cm
\foreach \i in {0, 1, 2}{
\foreach \j [evaluate=\j as \yin using 5-\j, evaluate=\j as \yout using 3-\j] in {0, 1, 2}{
\begin{scope}[shift={(\i\xsep, -\j\ysep)}]
\node[Input] (input) {};
\back{\node[Kernel, anchor=front north west] (k-\i-\j) at (input-x-\i-\yin) {};}
\node[Output, right=2cm of input] (output) {};
\back{\node[Cell, anchor=front north west] (o-\i-\j) at (output-x-\i-\yout) {};}
\foreach \a/\b in {front south east/front south west, front north
east/front north west, back north east/back north west}{
\draw[densely dashed, line width=.2pt] (k-\i-\j.\a) -- (o-\i-\j.\b);
}
\end{scope}
}
}
\end{tikzpicture}
\end{document}
```
下面是我自己写的包,帮助文档在[https://github.com/ZhiyuanLck/dnnplot](https://github.com/ZhiyuanLck/dnnplot "https://github.com/ZhiyuanLck/dnnplot")
![](/static/images/ext/zip.gif)dnnplot.zip
1 回答
6
知道原因了
`line width`包含在 node 的`text box`的宽度和高度中,因此使用`anchor=...`来设置偏移会导致线没有重合
```tex
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw, line width=1pt] (a) {};
\node[draw, line width=1pt, anchor=west] at (a.east) {};
\end{tikzpicture}
\end{document}
```
![](https://pics.latexstudio.net/data/images/201911/9c552d340a57407.png)
你的回答
请登录后回答
你的回答将会帮助更多人,请务必认真回答问题。