调整 tikz 框中的文本间距

调整 tikz 框中的文本间距

在下面给出的代码中(基于在GitHub),我该如何减少文本到框的距离tikz

在此处输入图片描述

代码

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{url}
\usepackage{multicol}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{esint}
\usepackage{amsfonts}
\usepackage{blox}
\usepackage{tikz}
\usetikzlibrary{quotes, decorations.pathmorphing, shapes, arrows.meta}

\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{enumitem}

\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{.5}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother

\DeclareMathOperator{\di}{d\!}

%======================================================================================
%   FONTS
%======================================================================================

\usepackage{unicode-math}  % loads 'fontspec' automatically
%\defaultfontfeatures{Ligatures=TeX} % 'Ligatures=TeX' is the default
% Normal font
\setmainfont{Fira Sans Light}[
     Numbers       = OldStyle,
     BoldFont      = Fira Sans Medium,
     ItalicFont    = Fira Sans Light Italic,
     BoldItalicFont= Fira Sans Medium Italic]
\setsansfont{Fira Sans Light}[
     Numbers       = OldStyle,
     BoldFont      = Fira Sans Medium,
     ItalicFont    = Fira Sans Light Italic,
     BoldItalicFont= Fira Sans Medium Italic]
% For source code
\setmonofont{Source Code Pro Light}[
     BoldFont=Source Code Pro]

%% Math font
\setmathfont{Asana Math} % or some other suitable font


\advance\topmargin-1in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.5in
\advance\evensidemargin-1.5in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}
%\colorbox[HTML]{e4e4e4}{\makebox[\textwidth-2\fboxsep][l]{texto}
\begin{document}

\begin{multicols*}{3}

\tikzstyle{mybox} = [draw=black, fill=white, very thick, font=\scriptsize,
    rectangle, rounded corners, inner sep=10pt, inner ysep=10pt]
\tikzstyle{fancytitle} =[fill=black, text=white, font=\scriptsize\bfseries]

%------------ Bandwidth and Noise ---------------
\begin{tikzpicture}
\node [mybox] (box){%
    \begin{minipage}{0.3\textwidth}
    A band limited signal cannot be time limited and a time-limited signal cannot be band limited.
    \end{minipage}
};
%------------ Bandwidth and Noise Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Bandwidth and Noise};
\end{tikzpicture}

%------------ Energy ---------------
\begin{tikzpicture}
\node [mybox] (box){%
    \begin{minipage}{0.3\textwidth}
        Energy $E = \int\limits_{-\infty}^{\infty}|x(t)|^{2}dt$ if $E$ is finite\\
        Power $P=\lim\limits_{T \to \infty}\frac{1}{T}\int\limits_{-T/2}^{T/2}|x(t)|^{2}dt$
    \end{minipage}
};
%------------ Energy Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Energy};
\end{tikzpicture}

%------------ Hilbert Transform ---------------
\begin{tikzpicture}
\node [mybox] (box){%
    \begin{minipage}{0.3\textwidth}
        \begin{tabular}{lp{4cm} l}

             Shifts the phase by $-90^{o}$ \hspace*{0.1cm}
    % https://tex.stackexchange.com/questions/175969/block-diagrams-using-tikz
\tikzstyle{block} = [draw, fill=white, rectangle,
    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.7, every node/.style={scale=0.7}, 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}\hspace*{3.5cm} $x(t)=
\hat{m}(t)$\\

$\hat{X}(f) = -j\text{sgn}(f)X(f)$\hspace{4.55cm} $\hat{x}(t)=\Hat{\Hat{m}}(t)$\\
$\cos2\pi f_{c}(t)\Rightarrow\sin2\pi f_{c}t$ \hspace*{0.4cm} $\cos(2\pi f_{c}(t)-\frac{\pi}{2})\Rightarrow\sin2\pi f_{c}t$ \hspace*{1cm} $=-m(t)$\\
$\sin2\pi f_{c}t \Rightarrow -\cos2\pi f_{c}t$
    \end{tabular}
    \end{minipage}
};
%------------ Hilbert Transform Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Hilbert Transform};
\end{tikzpicture}

%------------ Gram-Schmidt Content ---------------
\begin{tikzpicture}
\node [mybox] (box){%
    \begin{minipage}{0.3\textwidth}
    \begin{align*}
  v_{1} &= x_{1} \\
  v_{2} &= x_{2} - \frac{\langle x_2, v_1\rangle}{||v_{1}||^2}v_{1}\\
  &\shortvdotswithin{=}
  v_{n} &= x_{m} - \sum_{k=1}^{m-1} \frac{\langle x_{m},v_{k} \rangle}{||v_{k}||^{2}}v_{k}
    \end{align*}
    \end{minipage}
};
%------------ Gram-Schmidt Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Gram-Schmidt};
\end{tikzpicture}

\end{multicols*}
\end{document} 

答案1

以下是一长串的评论:

  1. 到上边界和下边界的距离由 控制inner ysep
  2. 您正在嵌套tizkpictures,即tikzpicture在另一个 的节点内有一个tikzpicture。这可能会产生严重的副作用,因此应避免。
  3. 您不必投入minipages节点,text width密钥可以让您以更少的麻烦获得相同的效果。

已在本《MWE》中部分实施

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{url}
\usepackage{multicol}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{esint}
\usepackage{amsfonts}
\usepackage{blox}
\usepackage{tikz}
\usetikzlibrary{quotes, decorations.pathmorphing, shapes, arrows.meta}

\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{makecell}

\tikzset{block/.style={draw, fill=white, rectangle,
    minimum height=1em, minimum width=1em]}}
\tikzset{sum/.style={draw, fill=white, circle, node distance=1cm}}
\tikzset{input/.style={coordinate}}
\tikzset{output/.style={coordinate}}
\tikzset{pinstyle/.style={pin edge={to-,thin,black}}}
\newsavebox\picbox
\sbox\picbox{\begin{tikzpicture}[scale=0.7, every node/.style={scale=0.7}, 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}}

\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{.5}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother

\DeclareMathOperator{\di}{d\!}

%======================================================================================
%   FONTS
%======================================================================================

\usepackage{unicode-math}  % loads 'fontspec' automatically
%\defaultfontfeatures{Ligatures=TeX} % 'Ligatures=TeX' is the default
% Normal font
\setmainfont{Fira Sans Light}[
     Numbers       = OldStyle,
     BoldFont      = Fira Sans Medium,
     ItalicFont    = Fira Sans Light Italic,
     BoldItalicFont= Fira Sans Medium Italic]
\setsansfont{Fira Sans Light}[
     Numbers       = OldStyle,
     BoldFont      = Fira Sans Medium,
     ItalicFont    = Fira Sans Light Italic,
     BoldItalicFont= Fira Sans Medium Italic]
% For source code
\setmonofont{Source Code Pro Light}[
     BoldFont=Source Code Pro]

%% Math font
\setmathfont{Asana Math} % or some other suitable font


\advance\topmargin-1in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.5in
\advance\evensidemargin-1.5in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}
%\colorbox[HTML]{e4e4e4}{\makebox[\textwidth-2\fboxsep][l]{texto}
\begin{document}

\begin{multicols*}{3}

\tikzset{mybox/.style={draw=black, fill=white, very thick, font=\scriptsize,
    rectangle, rounded corners, inner sep=10pt, inner ysep=6pt,text width=0.3\textwidth}}
\tikzset{fancytitle/.style={fill=black, text=white, font=\scriptsize\bfseries}}

%------------ Bandwidth and Noise ---------------
\begin{tikzpicture}
\node [mybox] (box){%
    A band limited signal cannot be time limited and a time-limited signal cannot be band limited.
};
%------------ Bandwidth and Noise Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Bandwidth and Noise};
\end{tikzpicture}

%------------ Energy ---------------
\begin{tikzpicture}
\node [mybox] (box){%
        Energy $E = \int\limits_{-\infty}^{\infty}|x(t)|^{2}dt$ if $E$ is finite\\
        Power $P=\lim\limits_{T \to \infty}\frac{1}{T}\int\limits_{-T/2}^{T/2}|x(t)|^{2}dt$
};
%------------ Energy Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Energy};
\end{tikzpicture}

%------------ Hilbert Transform ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\begin{tabular}{p{0.37\textwidth}p{0.25\textwidth}p{0.2\textwidth}}
\makecell[l]{Shifts the phase by $-90^\circ$\\
$\hat{X}(f) = -j\text{sgn}(f)X(f)$\\
$\cos2\pi f_{c}(t)\Rightarrow\sin2\pi f_{c}t$\\
$\cos(2\pi f_{c}(t)-\frac{\pi}{2})\Rightarrow\sin2\pi f_{c}t$ \\
$\sin2\pi f_{c}t \Rightarrow -\cos2\pi f_{c}t$
}
& \usebox\picbox & \makecell[r]{$x(t)=\hat{m}(t)$\\
$\hat{x}(t)=\Hat{\Hat{m}}(t)$\\
$=-m(t)$}
\end{tabular}
};
%------------ Hilbert Transform Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Hilbert Transform};
\end{tikzpicture}

%------------ Gram-Schmidt Content ---------------
\begin{tikzpicture}
\node [mybox] (box){%
\vspace*{-\baselineskip}
    \begin{align*}
  v_{1} &= x_{1} \\
  v_{2} &= x_{2} - \frac{\langle x_2, v_1\rangle}{||v_{1}||^2}v_{1}\\
  &\shortvdotswithin{=}
  v_{n} &= x_{m} - \sum_{k=1}^{m-1} \frac{\langle x_{m},v_{k} \rangle}{||v_{k}||^{2}}v_{k}
    \end{align*}
};
%------------ Gram-Schmidt Header ---------------------
\node[fancytitle, right=10pt] at (box.north west) {Gram-Schmidt};
\end{tikzpicture}

\end{multicols*}
\end{document} 

在此处输入图片描述

我没有做很多事情,比如删除不必要的包。这是因为我希望你用 来绘制这些框tcolorbox,因为它就是为这些事情而制作的。要看到这一点,请考虑示例

\documentclass{article}
\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[2][]{text width=0.6\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}
\begin{document}
\begin{mybox}{Bandwidth and noise}
A band limited signal cannot be time limited and a time-limited signal cannot be band limited.and options.
\end{mybox}
\end{document}

在此处输入图片描述

在我看来,它相当接近地复制了您的盒子。当然,我没有将您的完整代码转换为tcolorbox。这里的键topbottom允许您控制距离。

相关内容