减小框图尺寸

减小框图尺寸

我已使用以下代码绘制了框图。但是我想将其大小缩小到 70% 左右。我该怎么做?

\documentclass[10pt,a4paper]{article} 
\usepackage{tikz}
\usepackage[margin=25mm,showframe]{geometry}
%\usepackage{adjustbox}% <--- not needed
\usetikzlibrary{arrows,
                chains,% <--- new
                decorations.markings,
                shadows, shapes.arrows}

\tikzset{% <--- modified
    decision/.style = {diamond,draw, fill=blue!50},
        line/.style = {draw, -stealth, thick},
       block/.style = {rectangle, draw,  text width=4 em, minimum height=10 mm,
                       align=center}
        }
\makeatletter
\tikzset{suspend join/.code={\def\tikz@after@path{}}}
\makeatother

\begin{document}              
\begin{figure}[htbp]
\begin{tikzpicture}[thick,
          node distance = 0ex and 3em,
          start chain = A going right,
          every join/.style = {draw, -stealth, thick},
          block/.append style = {on chain=A, join}
                        ]
\node [block]   {A};% <-- A-1
\node [block,right=5em of A-1]    {B};
\node [block]   {C};
\node [block]   {D};
\node [block]   {E};% <-- A-5
\node [block,suspend join]  {Accom\-modating Text
                             inside a block needed};
\node [single arrow, draw=red, minimum height=3em, outer sep=0pt,
       right=0pt of A-5.east] {\vphantom{x}};
\end{tikzpicture}
\end{figure}
\end{document}

答案1

下面定义了一个宏\blocktext,它使用varwidth包的环境varwidth将宽度限制为4em,但如果不需要整个宽度,则允许宽度缩小:

\documentclass[10pt,a4paper]{article}
%\usepackage[margin=25mm,showframe]{geometry}
\usepackage{varwidth}
\usepackage{tikz}
\usetikzlibrary{arrows,
                chains,% <--- new
                decorations.markings,
                shadows, shapes.arrows}

\tikzset{%
    decision/.style = {diamond,draw, fill=blue!50},
        line/.style = {draw, -stealth, thick},
       block/.style = {rectangle, draw, minimum height=10mm,
                       align=center}
        }
\makeatletter
\tikzset{suspend join/.code={\def\tikz@after@path{}}}
\makeatother

\newcommand*{\blocktext}[1]{%
  \begin{varwidth}{4em}%
    \centering
    #1%
  \end{varwidth}%
}

\begin{document}
\begin{figure}[htbp]
\begin{tikzpicture}[thick,
          node distance = 0ex and 3em,
          start chain = A going right,
          every join/.style = {draw, -stealth, thick},
          block/.append style = {on chain=A, join}
                        ]
\node [block] {\blocktext{A}};
\node [block] {\blocktext{B}};
\node [block] {\blocktext{C}};
\node [block] {\blocktext{D}};
\node [block] {\blocktext{E}};
\node [block,suspend join]  {\blocktext{Accom\-modating Text
                             inside a block needed}};
\node [single arrow, draw=red, minimum height=3em, outer sep=0pt,
       right=0pt of A-5.east] {\vphantom{x}};
\end{tikzpicture}
\end{figure}
\end{document}

结果

相关内容