두 개의 tikz 사진과 캡션의 위치

두 개의 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두 그림이 두 줄로 표시됩니다. 하지만 나는 그것들을 나란히 두고 싶습니다.
  • 나는 다음과 같이 그림의 크기를 조정하려고 시도했습니다.이 답변하다. 하지만 제 경우에는 스케일링 매개변수를 어디에 넣어야 할지 모르겠습니다.

답변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매우 좁습니다. 저널이나 컨퍼런스의 여백은 일반적으로 25mm 미만으로 훨씬 더 좁습니다. 이 경우 block예를 들어 MWE(7em)에서와 같이 wide 를 사용할 수 있습니다 .

관련 정보