边界框位于页边距之外

边界框位于页边距之外

梅威瑟:

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}

%landscape
\usepackage{pdflscape}

%tikz
%https://www.sharelatex.com/blog/2013/08/29/tikz-series-pt3.html
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{file} = [rectangle, rounded corners, minimum width=4cm, minimum height=1cm,text centered, draw=black, fill=blue!30]
\tikzset{trapezium stretches=true} % http://tex.stackexchange.com/questions/58555/how-to-control-text-margin-in-tikz-shapes
\tikzstyle{output} = [trapezium, trapezium left angle=70, trapezium right angle=70, minimum width=1cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]


\begin{document}

\begin{landscape}

\begin{center}

\begin{tikzpicture}[node distance=7cm]

\useasboundingbox (current page.south west) rectangle (current page.north east);
\node (A) [file, xshift = 2cm] at (current bounding box.north west) {A};
\node (B) [file, right of=A] {B};
\node (C) [file, right of=B] {C};
\node (D) [file, below of=B, yshift = 5cm] {D};
\node (E) [output, below of=D, yshift = 5cm] {E};
\draw [red] (current bounding box.south east) rectangle (current bounding box.north west);

\draw [arrow] (A) -- (B);

\draw [arrow] (B) -- (C);
\draw [arrow] (B) -- (D);
\draw [arrow] (D) -- (E);

\end{tikzpicture}

\end{center}

\end{landscape}

\end{document}

在此处输入图片描述

这尤其成问题,因为它会在图像之前创建一个空白页。我该如何解决这个问题?使用边界框的主要原因是让图像从横向页面的左上角开始。

答案1

这将帮助您入门。它将创建为横向设置的节点(页面)。

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{tikz}

%landscape
\usepackage{pdflscape}

\begin{document}

\begin{landscape}
\thispagestyle{empty}
\noindent\begin{tikzpicture}[remember picture,overlay]
\ifodd\value{page}
  \coordinate (nw) at (1in+\topmargin+\headheight+\headsep+\linewidth-\paperheight,1in+\oddsidemargin+\topskip);
\else
  \coordinate (nw) at (1in+\topmargin+\headheight+\headsep+\linewidth-\paperheight,1in+\evensidemargin+\topskip);
\fi
\node (page) [anchor=north west,inner sep=0pt,outer sep=0pt,text height=\paperwidth,text width=\paperheight] at (nw) {};

\draw[red] (page.south west) -- (page.north east);
\draw[black] (page.north west) -- (page.south east);

\end{tikzpicture}
\end{landscape}

\end{document}

答案2

感谢 John Kormylo 的指导。

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{file} = [rectangle, rounded corners, minimum width=4cm, minimum height=1cm,text centered, draw=black, fill=blue!30]
\tikzset{trapezium stretches=true} % http://tex.stackexchange.com/questions/58555/how-to-control-text-margin-in-tikz-shapes
\tikzstyle{output} = [trapezium, trapezium left angle=70, trapezium right angle=70, minimum width=1cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]

%landscape
\usepackage{pdflscape}

\begin{document}

\begin{landscape}
\thispagestyle{empty}
\noindent\begin{tikzpicture}[remember picture,overlay,node distance=7cm]
\ifodd\value{page}
  \coordinate (nw) at (1in+\topmargin+\headheight+\headsep+\linewidth-\paperheight,1in+\oddsidemargin+\topskip);
\else
  \coordinate (nw) at (1in+\topmargin+\headheight+\headsep+\linewidth-\paperheight,1in+\evensidemargin+\topskip);
\fi
\node (page) [anchor=north west,inner sep=0pt,text height=\paperwidth,text width=\paperheight] at (nw) {};

\node (A) [file, xshift = 2in, yshift = -1in] at (page.north west) {A};
\node (B) [file, right of=A] {B};
\node (C) [file, right of=B] {C};
\node (D) [file, below of=B, yshift = 5cm] {D};
\node (E) [output, below of=D, yshift = 5cm] {E};

\draw [arrow] (A) -- (B);

\draw [arrow] (B) -- (C);
\draw [arrow] (B) -- (D);
\draw [arrow] (D) -- (E);

\draw[red] (page.south west) -- (page.north east);
\draw[black] (page.north west) -- (page.south east);

\end{tikzpicture}
\end{landscape}

\end{document}

在此处输入图片描述

相关内容