Со следующими кодами
\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
, то две картинки будут располагаться в два ряда; но я хочу, чтобы они располагались рядом. - Я попытался изменить масштаб изображения, как показано ниже.этот ответделает. Но я не знаю, куда в моем случае вставить параметры масштабирования.
решение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}
Ширина текста по умолчанию article
очень узкая. Журналы или конференции обычно имеют поля гораздо уже, менее 25 мм. В этом случае вы можете использовать wide block
, например, как в вашем MWE (7em).