我试图将 tikz 图像放入海报中,但没有成功。图像本身是正确的,但当我尝试将文件导入海报时,写入
\begin{figure}[htbp]
%\resizebox{\columnwidth}{!}{
\input{./Architecture.tex}%}
\caption{Architecture of the NCS \label{fig:NCS_Architecture}}
\end{figure}
输出如下:
缩放方面可能存在问题吗?如果有人能帮助我,我将非常高兴!
谢谢
我的图像代码:
\tikzstyle{block} = [draw, fill=blue!20, rectangle, minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controller};
\node [block, right of=controller, pin={[pinstyle]above:Disturbances},node distance=3cm] (system) {System};
\draw [->] (controller) -- node[name=u] {$u$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {Measurements};
\draw [draw,->] (input) -- node {$r$} (sum);
\draw [->] (sum) -- node {$e$} (controller);
\draw [->] (system) -- node [name=y] {$y$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$} node [near end] {$y_m$} (sum);
\end{tikzpicture}
以及海报文件:
\documentclass{sciposter}
\usepackage{lipsum}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{multicol}
\usepackage{graphicx,url}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\tikzstyle{block} = [draw, fill=blue!20, rectangle, minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
\newtheorem{Def}{Definition}
\newtheorem{theorem}{Theorem}
\title{TITLE}
\author{authors}
\begin{document}
\maketitle
%%% Begin of Multicols-Enviroment
\begin{multicols}{3}
%%% Abstract
\begin{abstract}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{abstract}
%%% Introduction
\section{Introduction}
\label{introduction}
\begin{figure}[htbp]
% \resizebox{\columnwidth}{!}{
\input{./Architecture.tex}%}
\caption{Architecture of the NCS \label{fig:NCS_Architecture}}
\end{figure}
\section{Setup}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\newcommand{\imsize}{0.45\columnwidth}
\end{multicols}
\end{document}
答案1
问题是由于在 tikz 图片中使用了cm
as 单位。由于 beamerposter 使用大字体,因此方框太大,并且2cm
中心之间的距离不足以避免重叠。
一种解决方案可以表达节点之间的距离,em
其中的维度取决于字体大小。更改代码以用于3em
每个原始代码cm
:
\documentclass{beamer}
\usepackage[orientation=portrait,size=a0,scale=1.6,debug]{beamerposter}
\usepackage{tikz}
\begin{document}
\tikzstyle{block} = [draw, fill=blue!20, rectangle,
minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=3em]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=6em]
% We start by placing the blocks
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum] (controller) {Controller};
\node [block, right of=controller, pin={[pinstyle]above:Disturbances},
node distance=9em] (system) {System};
% We draw an edge between the controller and system block to
% calculate the coordinate u. We need it to place the measurement block.
\draw [->] (controller) -- node[name=u] {$u$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {Measurements};
% Once the nodes are placed, connecting them is easy.
\draw [draw,->] (input) -- node {$r$} (sum);
\draw [->] (sum) -- node {$e$} (controller);
\draw [->] (system) -- node [name=y] {$y$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$}
node [near end] {$y_m$} (sum);
\end{tikzpicture}
\end{document}
结果看起来不错:
更新
第二种可能性是使用 tikz 的positioning
库。使用此库,相对定位的语法将从 更改为right of=sum
等right=of sum
,然后 tikz 会智能地将节点之间的距离视为节点边缘之间的距离,而不是中心之间的距离,从而避免重叠。
使用这种方法(并将距离cm
再次恢复为 ,而不是em
),代码将是:
\documentclass{beamer}
\usepackage[orientation=portrait,size=a0,scale=1.6,debug]{beamerposter}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\tikzstyle{block} = [draw, fill=blue!20, rectangle,
minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
% The block diagram code is probably more verbose than necessary
\begin{tikzpicture}[auto, node distance=3cm]
% We start by placing the blocks
\node [input, name=input] {};
\node [sum, right=of input] (sum) {};
\node [block, right=of sum] (controller) {Controller};
\node [block, right=of controller, pin={[pinstyle]above:Disturbances},
node distance=3cm] (system) {System};
% We draw an edge between the controller and system block to
% calculate the coordinate u. We need it to place the measurement block.
\draw [->] (controller) -- node[name=u] {$u$} (system);
\node [output, right=of system] (output) {};
\node [block, below=of u] (measurements) {Measurements};
% Once the nodes are placed, connecting them is easy.
\draw [draw,->] (input) -- node {$r$} (sum);
\draw [->] (sum) -- node {$e$} (controller);
\draw [->] (system) -- node [name=y] {$y$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$}
node [near end] {$y_m$} (sum);
\end{tikzpicture}
\end{document}
结果(这次更紧凑一些):