2

In the code below, the arrows going into and out of the block diagram box are too long.

enter image description here

How do I go about reducing the length of the arrows?

CODE:

\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
    off-topic: (i) \usepackage{colortbl} + \usepackage{xcolor} = \usepackage[table]{xcolor}; (ii) you use geometry, why you not use it for defining page layout? (iii) mathtools superseded of amsmath, so using it you not need to load amsmath, (iv) amsymb load also amsfonts ... – Zarko Oct 4 '18 at 23:03
2

You are using some deprecated syntax elements:

  • \tikzstyle{blabla}=[...] is superseded by \tikzset{blala/.style={...}};
  • Relative positioning is much more straightforward with the positioning library.
  • On the long run you may also want to abandon the arrows library in favor of arrows.meta.

Glad to see that you're using tcolorbox. As for your question, with positionin it is straightforward to place a node some distance right of som other node, e.g. \node [block, right=1cm of input] (controller) {h(t)};. Note that the position of = has changed compared to what you have, it is now before 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} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.