减少框图中箭头的长度

减少框图中箭头的长度

在下面的代码中,进出框图框的箭头太长。

在此处输入图片描述

我该如何减少箭头的长度?

代码:

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{esint}
\usepackage{amsfonts}
\usepackage{blox}
\usepackage{tikz}
\usetikzlibrary{quotes, decorations.pathmorphing, shapes, arrows.meta}
\usepackage[most]{tcolorbox}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{enumitem}

\advance\topmargin-1in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.5in
\advance\evensidemargin-1.5in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}

\begin{document}

\newtcolorbox{mybox}[2][]{text width=0.3\textwidth,fontupper=\scriptsize,
fonttitle=\bfseries\sffamily\scriptsize, colbacktitle=black,enhanced,
attach boxed title to top left={yshift=-2mm,xshift=3mm},
boxed title style={sharp corners},top=3pt,bottom=2pt,
  title=#2,colback=white}

%%------------ Hilbert Transform ---------------

\begin{mybox}{Hilbert Transform}
\vspace*{0.5cm}
    % https://tex.stackexchange.com/questions/175969/block-diagrams-using-tikz
\tikzstyle{block} = [draw, fill=white, rectangle, scale=0.9,
    minimum height=1em, minimum width=1em]
\tikzstyle{sum} = [draw, fill=white, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[scale=0.8, rounded corners, every node/.style={scale=1}, remember picture,overlay, auto, node distance=2cm,>=latex']

    \node [input, name=input] {};
    \node [block, right of=input] (controller) {h(t)};
    \node [output, right of = controller, name=output] {};

    \draw [->] (input) -- node[name=$x(t)$] {$x(t)$} (controller);
    \draw [->] (controller) -- node{$\hat{x}(t)$} (output);

\end{tikzpicture}
\vspace*{0.5cm}
\end{mybox}

\end{document} 

答案1

您正在使用一些已弃用的语法元素:

  • \tikzstyle{blabla}=[...]被取代\tikzset{blala/.style={...}}
  • 使用该库,相对定位更加直接positioning
  • 从长远来看,您可能还想放弃arrows图书馆,转而采用arrows.meta

很高兴看到您使用tcolorbox。至于您的问题,使用positionin可以很直接地将一个节点放置在其他节点右侧一定距离处,例如\node [block, right=1cm of input] (controller) {h(t)};。请注意 的位置=与您拥有的位置相比已发生变化,现在位于 之前of

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{esint}
\usepackage{amsfonts}
\usepackage{blox}
\usepackage{tikz}
\usetikzlibrary{quotes, decorations.pathmorphing, shapes,
arrows.meta,positioning}
\usepackage[most]{tcolorbox}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{enumitem}

\advance\topmargin-1in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.5in
\advance\evensidemargin-1.5in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}

\begin{document}

\newtcolorbox{mybox}[2][]{text width=0.3\textwidth,fontupper=\scriptsize,
fonttitle=\bfseries\sffamily\scriptsize, colbacktitle=black,enhanced,
attach boxed title to top left={yshift=-2mm,xshift=3mm},
boxed title style={sharp corners},top=3pt,bottom=2pt,
colframe=black , %<- comment by TeXnician https://tex.stackexchange.com/questions/453737/adjust-text-spacing-in-tikz-box/453741#comment1141038_453741
  title=#2,colback=white}

%%------------ Hilbert Transform ---------------

\begin{mybox}{Hilbert Transform}
\vspace*{0.5cm}
    % https://tex.stackexchange.com/questions/175969/block-diagrams-using-tikz
\tikzset{block/.style={draw, fill=white, rectangle, scale=0.9,
    minimum height=1em, minimum width=1em},
sum/.style={draw, fill=white, circle, node distance=1cm},
input/.style={coordinate},
output/.style={coordinate},
pinstyle/.style={pin edge={to-,thin,black}}}

\begin{tikzpicture}[scale=0.8, rounded corners, every node/.style={scale=1}, remember picture,overlay, auto, node distance=2cm,>=latex']
    \node [input, name=input] {};
    \node [block, right=1cm of input] (controller) {h(t)};
    \node [output, right= 1cm of controller, name=output] {};

    \draw [->] (input) -- node {$x(t)$} (controller);
    \draw [->] (controller) -- node{$\hat{x}(t)$} (output);
\end{tikzpicture}
\vspace*{0.5cm}
\end{mybox}

\end{document} 

在此处输入图片描述

相关内容