使用current page
命令这个答案
\documentclass[tikz,border=4pt]{standalone}
\usepackage{bm}
\usetikzlibrary{fadings}
\begin{document}
\def\hori{3}
\def\vert{2}
\def\zColor{black!40!green}
\def\EkColor{yellow!40}
\begin{tikzpicture}
\path
(0,0) node (v) {$v$}
(v) ++ (\vert,0) node (+1) {$\oplus$}
(v) ++ (\vert,\vert) node (y1) {$y_1$}
(+1) ++ (\hori,0) node (+2) {$\oplus$}
(+1) ++ (\hori,\vert) node (y2) {$y_2$}
(+2) ++ (\hori,0) node (+3) {$\oplus$}
(+2) ++ (\hori,\vert) node (y3) {$y_3$}
(+3) ++ (0.75*\hori,0) node (+dots) {$~\cdots~$}
(+dots) ++ (0.75*\hori,0) node (+n) {$\oplus$}
(+dots) ++ (0.75*\hori,\vert) node (yn) {$y_n$}
(+n) ++ (\hori,0) node (z) {${\color{\zColor}\bm{z}}$};
\draw
(y1) edge [-stealth] (+1)
(y2) edge [-stealth] (+2)
(y3) edge [-stealth] (+3)
(yn) edge [-stealth] (+n);
\draw
(v) edge [-stealth] (+1)
(+1) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+2)
(+2) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+3)
(+3) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+dots)
(+dots) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+n)
(+n) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (z) ;
\end{tikzpicture}
\begin{tikzpicture}
\path
(0,0) node (v) {$v$}
(v) ++ (\vert,0) node (+1) {$\oplus$}
(v) ++ (\vert,\vert) node (y1) {$y_1$}
(+1) ++ (\hori,0) node (+2) {$\oplus$}
(+1) ++ (\hori,\vert) node (y2) {$y_2$}
(+2) ++ (\hori,0) node (+3) {$\oplus$}
(+2) ++ (\hori,\vert) node (y3) {$y_3$}
(+3) ++ (0.75*\hori,0) node (+dots) {$~\cdots~$}
(+dots) ++ (0.75*\hori,0) node (+n) {$\oplus$}
(+dots) ++ (0.75*\hori,\vert) node (yn) {$y_n$}
(+n) ++ (\hori,0) node (z) {${\color{\zColor}\bm{z}}$}
(+n) ++ (\hori,\vert) node (topr) {};
\draw
(y1) edge [-stealth] (+1)
(y2) edge [-stealth] (+2)
(y3) edge [-stealth] (+3)
(yn) edge [-stealth] (+n);
\draw
(v) edge [-stealth] (+1)
(+1) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} node [below] (botl) {\phantom{$E_k$}} (+2)
(+2) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+3)
(+3) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+dots)
(+dots) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+n)
(+n) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (z) ;
\fill[black, path fading=west] (current page.south west) rectangle (current page.north east);
\end{tikzpicture}
代码的第一部分产生了正确的图像:
而第二段代码却没有:
而不是遮蔽整个页面,
- 它只遮住下半部分,
- 它没有遮挡最右边的内容
- 并且在此过程中它会改变页面大小。
我该如何正确地做到这一点,即遮蔽正确的区域而不改变页面的尺寸?
答案1
您可能只对图片进行阴影处理。如果您移除,border=4pt
则整个图片都会被阴影覆盖。
\documentclass[tikz,border=4pt]{standalone}
\usepackage{bm}
\usetikzlibrary{fadings}
\begin{document}
\def\hori{3}
\def\vert{2}
\def\zColor{black!40!green}
\def\EkColor{yellow!40}
\begin{tikzpicture}
\path
(0,0) node (v) {$v$}
(v) ++ (\vert,0) node (+1) {$\oplus$}
(v) ++ (\vert,\vert) node (y1) {$y_1$}
(+1) ++ (\hori,0) node (+2) {$\oplus$}
(+1) ++ (\hori,\vert) node (y2) {$y_2$}
(+2) ++ (\hori,0) node (+3) {$\oplus$}
(+2) ++ (\hori,\vert) node (y3) {$y_3$}
(+3) ++ (0.75*\hori,0) node (+dots) {$~\cdots~$}
(+dots) ++ (0.75*\hori,0) node (+n) {$\oplus$}
(+dots) ++ (0.75*\hori,\vert) node (yn) {$y_n$}
(+n) ++ (\hori,0) node (z) {${\color{\zColor}\bm{z}}$};
\draw
(y1) edge [-stealth] (+1)
(y2) edge [-stealth] (+2)
(y3) edge [-stealth] (+3)
(yn) edge [-stealth] (+n);
\draw
(v) edge [-stealth] (+1)
(+1) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+2)
(+2) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+3)
(+3) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+dots)
(+dots) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+n)
(+n) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (z) ;
\end{tikzpicture}
\begin{tikzpicture}
\path
(0,0) node (v) {$v$}
(v) ++ (\vert,0) node (+1) {$\oplus$}
(v) ++ (\vert,\vert) node (y1) {$y_1$}
(+1) ++ (\hori,0) node (+2) {$\oplus$}
(+1) ++ (\hori,\vert) node (y2) {$y_2$}
(+2) ++ (\hori,0) node (+3) {$\oplus$}
(+2) ++ (\hori,\vert) node (y3) {$y_3$}
(+3) ++ (0.75*\hori,0) node (+dots) {$~\cdots~$}
(+dots) ++ (0.75*\hori,0) node (+n) {$\oplus$}
(+dots) ++ (0.75*\hori,\vert) node (yn) {$y_n$}
(+n) ++ (\hori,0) node (z) {${\color{\zColor}\bm{z}}$}
(+n) ++ (\hori,\vert) node (topr) {};
\draw
(y1) edge [-stealth] (+1)
(y2) edge [-stealth] (+2)
(y3) edge [-stealth] (+3)
(yn) edge [-stealth] (+n);
\draw
(v) edge [-stealth] (+1)
(+1) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} node [below] (botl) {\phantom{$E_k$}} (+2)
(+2) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+3)
(+3) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+dots)
(+dots) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+n)
(+n) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (z) ;
\fill[black, path fading=west] (current bounding box.south west)
rectangle (current bounding box.north east);
\end{tikzpicture}
\end{document}
至于您的评论:
\documentclass[tikz,border=4pt]{standalone}
\usepackage{bm}
\usetikzlibrary{fadings}
\begin{document}
\def\hori{3}
\def\vert{2}
\def\zColor{black!40!green}
\def\EkColor{yellow!40}
\begin{tikzpicture}
\path
(0,0) node (v) {$v$}
(v) ++ (\vert,0) node (+1) {$\oplus$}
(v) ++ (\vert,\vert) node (y1) {$y_1$}
(+1) ++ (\hori,0) node (+2) {$\oplus$}
(+1) ++ (\hori,\vert) node (y2) {$y_2$}
(+2) ++ (\hori,0) node (+3) {$\oplus$}
(+2) ++ (\hori,\vert) node (y3) {$y_3$}
(+3) ++ (0.75*\hori,0) node (+dots) {$~\cdots~$}
(+dots) ++ (0.75*\hori,0) node (+n) {$\oplus$}
(+dots) ++ (0.75*\hori,\vert) node (yn) {$y_n$}
(+n) ++ (\hori,0) node (z) {${\color{\zColor}\bm{z}}$};
\draw
(y1) edge [-stealth] (+1)
(y2) edge [-stealth] (+2)
(y3) edge [-stealth] (+3)
(yn) edge [-stealth] (+n);
\draw
(v) edge [-stealth] (+1)
(+1) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+2)
(+2) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+3)
(+3) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+dots)
(+dots) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+n)
(+n) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (z) ;
\end{tikzpicture}
\begin{tikzpicture}
\path
(0,0) node (v) {$v$}
(v) ++ (\vert,0) node (+1) {$\oplus$}
(v) ++ (\vert,\vert) node (y1) {$y_1$}
(+1) ++ (\hori,0) node (+2) {$\oplus$}
(+1) ++ (\hori,\vert) node (y2) {$y_2$}
(+2) ++ (\hori,0) node (+3) {$\oplus$}
(+2) ++ (\hori,\vert) node (y3) {$y_3$}
(+3) ++ (0.75*\hori,0) node (+dots) {$~\cdots~$}
(+dots) ++ (0.75*\hori,0) node (+n) {$\oplus$}
(+dots) ++ (0.75*\hori,\vert) node (yn) {$y_n$}
(+n) ++ (\hori,0) node (z) {${\color{\zColor}\bm{z}}$}
(+n) ++ (\hori,\vert) node (topr) {};
\draw
(y1) edge [-stealth] (+1)
(y2) edge [-stealth] (+2)
(y3) edge [-stealth] (+3)
(yn) edge [-stealth] (+n);
\draw
(v) edge [-stealth] (+1)
(+1) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} node [below] (botl) {\phantom{$E_k$}} (+2)
(+2) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+3)
(+3) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+dots)
(+dots) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (+n)
(+n) edge [-stealth] node [rectangle, draw=black, fill=\EkColor] {$E_k$} (z) ;
\fill[black, path fading=west] (current bounding box.south west)
rectangle (current bounding box.north);
\fill[black] ([xshift=-0.5\pgflinewidth]current bounding box.south)
rectangle (current bounding box.north east);
\end{tikzpicture}
\end{document}