我怎样才能在同一行中并排放置 3 或 4 个子图?我试过一次,但我得到的最好结果就是同一行中并排放置 2 个子图。
我目前的代码是:
\documentclass[12pt,a4paper,titlepage,twoside,openright]{article}
\usepackage[english,greek]{babel}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{tkz-tab}
\usepackage{caption}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.30\textwidth}
\centering
\begin{tikzpicture}
\draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
\draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
\draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,2) node[left] {$\text{Η}$} to [out=0, in=90] (2,0)node[below]{$\text{Θ}$};
\draw[<-, Cyan] (45:2.1) -- (45:2.9);
\end{tikzpicture}
\label{fig:subfig8}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.30\textwidth}
\centering
\begin{tikzpicture}
\draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
\draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
\draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,2.7) node[left] {$\text{Γ}$} to [out=0, in=90] (1.5,0)node[below]{$\text{Δ}$};
\draw[<-, Cyan] (45:2.2) -- (45:2.9);
\end{tikzpicture}
\label{fig:subfig9}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.35\textwidth}
\centering
\begin{tikzpicture}
\draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
\draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
\draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,1.5) node[left] {$\text{E}$} to [out=0, in=90] (2.5,0)node[below]{$\text{Z}$};
\draw[<-, Cyan] (45:2.1) -- (45:2.5);
\end{tikzpicture}
\label{fig:subfig10}
\caption{}
\end{subfigure}
\captionof{figure}{τεχνολογία και στα δυο αγαθά} \label{fig:subfig1.a.4}
\end{figure}
\end{document}
答案1
以下代码用于 3,它需要包subcaption
。如果有超过 3 个,请更改0.30\textwidth
参数subfigure
以相应地调整每个的大小
\begin{figure}
\begin{subfigure}[b]{0.30\textwidth}
\centering
\resizebox{\linewidth}{!}{\input{figures/a.tikz}}
\caption{Caption A}
\label{fig:A}
\end{subfigure}
\begin{subfigure}[b]{0.30\textwidth}
\centering
\resizebox{\linewidth}{!}{\input{figures/b.tikz}}
\caption{Caption B}
\label{fig:B}
\end{subfigure}
\begin{subfigure}[b]{0.30\textwidth}
\centering
\resizebox{\linewidth}{!}{\input{figures/c.tikz}}
\caption{Caption C}
\label{fig:C}
\end{subfigure}
\end{figure}
编辑:我花了时间修复你的代码。你缺少了\resizebox
以便正确定位你的 tikz 图形。请参阅下面的代码和结果
\documentclass[12pt,a4paper,titlepage,twoside,openright]{article}
\usepackage[english,greek]{babel}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{tkz-tab}
\usepackage{caption}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.32\textwidth}
\centering
\resizebox{\linewidth}{!}{
\begin{tikzpicture}
\draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
\draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
\draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,2) node[left] {$\text{Η}$} to [out=0, in=90] (2,0)node[below]{$\text{Θ}$};
\draw[<-, Cyan] (45:2.1) -- (45:2.9);
\end{tikzpicture}
}
\caption{Subfigure A}
\label{fig:subfig8}
\end{subfigure}
\begin{subfigure}[b]{0.32\textwidth}
\centering
\resizebox{\linewidth}{!}{
\begin{tikzpicture}
\draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
\draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
\draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,2.7) node[left] {$\text{Γ}$} to [out=0, in=90] (1.5,0)node[below]{$\text{Δ}$};
\draw[<-, Cyan] (45:2.2) -- (45:2.9);
\end{tikzpicture}
}
\caption{Subfigure B}
\label{fig:subfig9}
\end{subfigure}
\begin{subfigure}[b]{0.32\textwidth}
\centering
\resizebox{\linewidth}{!}{
\begin{tikzpicture}
\draw (0,3) node[left] {$\text{A}$} to[out=0,in=90] (3,0) node[below]{$\text{B}$};
\draw[->, very thick] (-.1,0) -- (4,0) node[below] {$\text{αγαθό Α}$};
\draw[->, very thick] (0,-.1) -- (0,4) node[left]{$\text{αγαθό Β}$};
\draw[ForestGreen] (0,1.5) node[left] {$\text{E}$} to [out=0, in=90] (2.5,0)node[below]{$\text{Z}$};
\draw[<-, Cyan] (45:2.1) -- (45:2.5);
\end{tikzpicture}
}
\caption{Subfigure C}
\label{fig:subfig10}
\end{subfigure}
\caption{τεχνολογία και στα δυο αγαθά}
\label{fig:subfig1.a.4}
\end{figure}
\end{document}
我希望这有帮助!
更新:修复了调整{
大小框中缺失的问题。