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

在此处输入图片描述

相关内容