2つのtikz画像とキャプションの位置

2つのtikz画像とキャプションの位置

以下のコードで

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{intersections,shapes,arrows,positioning}

\begin{document}
\tikzstyle{block} = [rectangle, draw, 
text width=7em, text centered, rounded corners, minimum height=3em]

\tikzstyle{line} = [draw, -latex']

\tikzstyle{cloud} = [draw, ellipse, node distance=4.5cm,
minimum height=2.5em] 

\begin{figure} 

\begin{tikzpicture}[node distance = 3cm,auto]

\node [block] (firm) {Bob's favorite $i$};
\node [cloud, right of= firm] (C) {country $A$};
\node [cloud, below right of=firm] (C') {Alice $B$};

\path [line, thick] (firm) -- node {t}(C');
\path [line, thick] (C') -- node {t}(C);
\path [line,dashed, very thick] (firm) --  node {t+1}(C);
\end{tikzpicture}
\hspace{1cm}% NO SPACE!
\begin{tikzpicture}[node distance = 3cm,auto]

\node [block] (firm) {Bob's favorite $i$};
\node [cloud, right of= firm] (C) {country $A$};
\node [cloud, below right of=firm] (C') {Alice $B$};

\path [line, thick] (firm) -- node {t}(C');
\path [line, thick] (C') -- node {t}(C);
\path [line,dashed, very thick] (firm) --  node {t+1}(C);
\end{tikzpicture}

\caption{Bob and Alice}
\end{figure}

\end{document}

私は持っている ここに画像の説明を入力してください

中央の図形はどうやって作るのでしょうか?


次のような問題があります:

  • \centering環境内で使用するとfigure、2 つの画像は 2 行になりますが、並べて表示したいのです。
  • 私は次のように画像のサイズを変更してみましたこの答えはい。しかし、私の場合、スケーリングパラメータをどこに配置すればよいかわかりません。

答え1

画像は比較的単純なので、再描画することをお勧めします。このとき、配置とスタイルの定義に新しい構文を使用します。再描画では、実際にはいくつかのパラメータを変更するだけで済み、画像の幅が縮小されます。

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows, 
                calc, % added
                intersections, positioning, shapes}

\usepackage{showframe}

\begin{document}
\tikzset{ % changed from tikzstyle
block/.style = {rectangle, draw, rounded corners,
                text width=4em, % reduced, now text is in two lines
                minimum height=3em, align=center},
 line/.style = {draw, thick, -latex'},
cloud/.style = {draw, ellipse, minimum height=2.5em, inner xsep=0pt}
        }

\begin{figure}
\centering
    \begin{tikzpicture}[
node distance = 2cm and 1.5cm, % changed (reduced)
        auto]
\node [block] (firm) {Bob's favorite $i$};
\node [cloud, right=of firm] (C) {country $A$}; % new syntax according to positioning library
\node [cloud, below=of $(firm)!0.5!(C)$] (C') {Alice $B$}; % use of calc library

\path [line] (firm) -- node {t}(C');
\path [line] (C') -- node {t}(C);
\path [line,dashed, very thick] (firm) --  node {t+1} (C);
    \end{tikzpicture}
\hfil % for distance between images
    \begin{tikzpicture}[
node distance = 2cm and 1.5cm,
        auto]
\node [block] (firm) {Bob's favorite $i$};
\node [cloud, right=of firm] (C) {country $A$};
\node [cloud, below=of $(firm)!0.5!(C)$] (C') {Alice $B$};

\path [line] (firm) -- node {t}(C');
\path [line] (C') -- node {t}(C);
\path [line,dashed, very thick] (firm) --  node {t+1} (C);
    \end{tikzpicture}
    \caption{Bob and Alice}
\end{figure}

\end{document}

ここに画像の説明を入力してください

のデフォルトのテキスト幅は非常に狭いです。ジャーナルや会議の余白は通常、25 mm 未満と、はるかに狭くなります。この場合は、たとえば MWE (7em) のように、article広い を使用できます。block

関連情報