0

I have a drawn a block diagram with the following code. However I want to reduce its size to around 70 %. How can I do that.

\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}
4
  • you could use the package tikzscale and \includegraphics[width=0.7\textwidth]{file.tikz}. Then the text size stays the same (which looks better, but might become problematic inside the boxes)
    – crateane
    Apr 16, 2016 at 8:03
  • How can I get .tikz file. I tried to save the file as sys.tikz but texmaker saves it as sys.tikz.tex, which is not recognized by \includegraphics command
    – Ehsa
    Apr 16, 2016 at 12:45
  • Then you should just rename it to sys.tikz ;) Only certain files, like .pdf, .png are recognized by \includegraphics. With \usepackage{tikzscale} it's also possible for .tikz Inside the file, you just put the tikzpicture-environment
    – crateane
    Apr 16, 2016 at 14:30
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. Jan 12, 2017 at 17:00

1 Answer 1

1

The following defines a macro \blocktext, which uses environment varwidth of package varwidth to limit the width to 4em, but allowing the width to shrink, if the full width is not needed:

\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}

Result

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .