错误输出的图片

错误输出的图片

这句话\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);当然是取自使用 TikZ 在图像上绘图,现在会产生错误。我必须承认我没有跟上 LaTeX,特别是 TikZ 的步伐。为什么这不起作用?

错误输出的图片

在此处输入图片描述

错误信息

! Arithmetic overflow.
\pgf@pathgrid ...de \c@pgf@counta by\c@pgf@countb 
                                                  \relax \pgfutil@tempdima =...
l.42 ... lines,xstep=.1,ystep=.1] (0,0) grid (1,1)
                                                  ; %%% --- this is the firs...
I can't carry out that multiplication or division,
since the result is out of range.

MWE 用于额外图片.pdf

\documentclass[
]{standalone}

\usepackage{
    tikz,
}

\usepackage{lmodern}
\usepackage{microtype}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{tikzpicture}
\filldraw[fill=black!50] (0,0) rectangle (4,2);
\end{tikzpicture}
\end{document}

平均能量损失

\documentclass[
fontsize=11pt,
DIV=12,
]{standalone}

\usepackage{
    tikz,
}

\usetikzlibrary{
    calc,
}

\usepackage{lmodern}
\usepackage{microtype}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{tikzpicture}[
every node/.style={
    node font=\sffamily,
},
month/.style={
    rectangle,
    draw=black,
    very thick,
    fill=black!40,
},
normal/.style={
    draw,
    font=\small,
    rectangle,
},
]
\node [month, anchor=west] (AAA) at (0,0) {kkkkk};
\node [normal, anchor=west] (AAAstuff) at ($(AAA.east)+(1cm,0)$) {Text};

\node[anchor=west, inner sep=0] (ENVimage) at ($(AAAstuff.east)+(2cm,0)$) {\includegraphics[width=2cm]{extra-picture.pdf}};
\begin{scope}[x={(ENVimage.south east)},y={(ENVimage.north west)}]
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1); %%% --- this is the first line that yields the non-working MWE
%\draw[help lines,] (0,0) grid (1,1);
%\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
%\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
%\node[fill=white] at (0.5,0.5) {111111};
\end{scope}

\end{tikzpicture}
\end{document}

答案1

我猜你想要这样的东西。

\documentclass[
fontsize=11pt,
DIV=12,
]{standalone}

\usepackage{
    tikz,
}

\usetikzlibrary{
    calc,
}

\usepackage{lmodern}
\usepackage{microtype}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{tikzpicture}[
every node/.style={
    node font=\sffamily,
},
month/.style={
    rectangle,
    draw=black,
    very thick,
    fill=black!40,
},
normal/.style={
    draw,
    font=\small,
    rectangle,
},
]
\node [month, anchor=west] (AAA) at (0,0) {kkkkk};
\node [normal, anchor=west] (AAAstuff) at ($(AAA.east)+(1cm,0)$) {Text};

\node[anchor=west, inner sep=0] (ENVimage) at ($(AAAstuff.east)+(2cm,0)$)
{\includegraphics[width=2cm]{example-image-duck.pdf}};
\begin{scope}[shift={(ENVimage.south west)},x={(ENVimage.south east)},y={(ENVimage.north west)}]
\draw[help lines,xstep=0.1,ystep=0.1] (0,0) grid (1,1); %%% --- this is the first line that yields the non-working MWE
%\draw[help lines,] (0,0) grid (1,1);
%\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
%\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
%\node[fill=white] at (0.5,0.5) {111111};
\end{scope}

\end{tikzpicture}
\end{document}

在此处输入图片描述

我认为您使用了将网格放在原点图像顶部的代码,但是您的图像不在原点,所以我添加了一下,shift={(ENVimage.south west)}没有问题。

相关内容