將 tikzpicture 嵌入到 includegraphics 環境中

將 tikzpicture 嵌入到 includegraphics 環境中

我想包含一個\tikzpicture 這樣\includegraphics我可以將我的圖片設定為頁面的一半。

有人能幫我嗎 ?這是我的 MWE :

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz} 
    \usetikzlibrary{chains}
    \usetikzlibrary{positioning}
    \usetikzlibrary{backgrounds}
    \usetikzlibrary{trees}

\usetikzlibrary{arrows,automata}
\usepackage{epstopdf}
\definecolor{mycolor}{RGB}{8,108,131}
\usepackage{array}
\usepackage{adjustbox}      
\usetikzlibrary{shapes}
\usepackage{colortbl}
\begin{document}        
    \begin{figure}[h!]
        \centering
        \includegraphics[width=0.5\textwidth]{%to fill 1/2 of the page and to see entierly my tikzpicture
        \begin{tikzpicture}
            [ 
            show background rectangle,
            background rectangle/.style={fill=gray!10}
            ];
            \node[rounded corners=3mm, fill=mycolor!20] (1) [draw,minimum width=2.4cm,minimum height=2.4cm] {Live functionnal OpenStack Cluster};
            \node[rounded corners=3mm, fill=mycolor!20] (2) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 1] {Configure Tempest};
            \node[rounded corners=3mm, fill=mycolor!20] (3) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 2] {Run Tempest Tests};            
            \node[rounded corners=3mm, fill=mycolor!20] (4) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 3] {Collect test results};
            \node[rounded corners=3mm, fill=mycolor!20] (5) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 4] {Analyse test results};
            \node[rounded corners=3mm, fill=mycolor!20] (6) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 5] {Run Tempest cleanup};
            \draw[thick,->] (1) -- node[above]{} (2);
            \draw[thick,->] (2) -- node[above]{} (3);
            \draw[thick,->] (3) -- node[above]{} (4);
            \draw[thick,->] (4) -- node[above]{} (5);
            \draw[thick,->] (5) -- node[above]{} (6);
          %  \path[mycolor,->,thick] (root) edge  [loop left] node {Auto-signé} ();
        \end{tikzpicture}
        }
        \caption{Chaînage des signatures pour Let's encrypt}
    \end{figure}

\end{document} 

謝謝你的幫助

答案1

我想你想要一個resizebox

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz} 
    \usetikzlibrary{chains}
    \usetikzlibrary{positioning}
    \usetikzlibrary{backgrounds}
    \usetikzlibrary{trees}

\usetikzlibrary{arrows,automata}
\usepackage{epstopdf}
\definecolor{mycolor}{RGB}{8,108,131}
\usepackage{array}
\usepackage{adjustbox}      
\usetikzlibrary{shapes}
\usepackage{colortbl}
\begin{document}        
    \begin{figure}[h!]
        \centering
        \resizebox{0.5\textwidth}{!}{%to fill 1/2 of the page and to see entierly my tikzpicture
        \begin{tikzpicture}
            [ 
            show background rectangle,
            background rectangle/.style={fill=gray!10}
            ];
            \node[rounded corners=3mm, fill=mycolor!20] (1) [draw,minimum width=2.4cm,minimum height=2.4cm] {Live functionnal OpenStack Cluster};
            \node[rounded corners=3mm, fill=mycolor!20] (2) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 1] {Configure Tempest};
            \node[rounded corners=3mm, fill=mycolor!20] (3) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 2] {Run Tempest Tests};            
            \node[rounded corners=3mm, fill=mycolor!20] (4) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 3] {Collect test results};
            \node[rounded corners=3mm, fill=mycolor!20] (5) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 4] {Analyse test results};
            \node[rounded corners=3mm, fill=mycolor!20] (6) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 5] {Run Tempest cleanup};
            \draw[thick,->] (1) -- node[above]{} (2);
            \draw[thick,->] (2) -- node[above]{} (3);
            \draw[thick,->] (3) -- node[above]{} (4);
            \draw[thick,->] (4) -- node[above]{} (5);
            \draw[thick,->] (5) -- node[above]{} (6);
          %  \path[mycolor,->,thick] (root) edge  [loop left] node {Auto-signé} ();
        \end{tikzpicture}
        }
        \caption{Chaînage des signatures pour Let's encrypt}
    \end{figure}

    \begin{figure}[h!]
        \centering
        \resizebox{\textwidth}{!}{%to fill 1/2 of the page and to see entierly my tikzpicture
        \begin{tikzpicture}
            [ 
            show background rectangle,
            background rectangle/.style={fill=gray!10}
            ];
            \node[rounded corners=3mm, fill=mycolor!20] (1) [draw,minimum width=2.4cm,minimum height=2.4cm] {Live functionnal OpenStack Cluster};
            \node[rounded corners=3mm, fill=mycolor!20] (2) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 1] {Configure Tempest};
            \node[rounded corners=3mm, fill=mycolor!20] (3) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 2] {Run Tempest Tests};            
            \node[rounded corners=3mm, fill=mycolor!20] (4) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 3] {Collect test results};
            \node[rounded corners=3mm, fill=mycolor!20] (5) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 4] {Analyse test results};
            \node[rounded corners=3mm, fill=mycolor!20] (6) [draw,minimum width=2.4cm,minimum height=2.4cm, right=1cm of 5] {Run Tempest cleanup};
            \draw[thick,->] (1) -- node[above]{} (2);
            \draw[thick,->] (2) -- node[above]{} (3);
            \draw[thick,->] (3) -- node[above]{} (4);
            \draw[thick,->] (4) -- node[above]{} (5);
            \draw[thick,->] (5) -- node[above]{} (6);
          %  \path[mycolor,->,thick] (root) edge  [loop left] node {Auto-signé} ();
        \end{tikzpicture}
        }
        \caption{Chaînage des signatures pour Let's encrypt}
    \end{figure}
\end{document} 

在此輸入影像描述

相關內容