![beamer 中的 tikzpicture](https://linux22.com/image/371546/beamer%20%E4%B8%AD%E7%9A%84%20tikzpicture.png)
我有以下 MWE:
\documentclass[xcolor=pdftex,t,11pt]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{My presentation}
\framesubtitle{A theory}
\begin{itemize}
\item Consider the following two alternative situations:
\begin {figure}
\begin{minipage}{0.5\textheight}
\begin{tikzpicture}[scale=0.4]
\tiny
\draw [thick, ->](-0.3,0)-- (0,0) -- (8,0) node [below] {Political Institutions};
\draw [thick, ->](0,-0.5)-- (0,0) -- (0,5) node [left] {Economic Institutions};
\draw (0.2,3.7) to [out=290,in=180] (3.75,1);
\draw (3.75,1) to [out=360,in=260] (7.6,3.9);
\node [above] at (7.5,4) {};
\end{tikzpicture}
\caption{$U$--shape relationship}
\end{minipage}
\begin{minipage}{0.5\textheight}
\begin{tikzpicture}[scale=0.4]
\tiny
\draw [thick, ->](-0.3,0)-- (0,0) -- (8,0) node [below] {Political Institutions};
\draw [thick, ->](0,-0.5)-- (0,0) -- (0,5) node [left] {Economic Institutions};
\draw (3.75,1) to [out=360,in=260] (7.6,3.9);
\node [above] at (7.5,4) {};
\end{tikzpicture}
\caption{Monotonically increasing relationship}
\end{minipage}
\end{figure}
\end{itemize}
\end{frame}
\end{document}
您可能注意到,这两个图一个在另一个之上,而我希望它们并排。我该如何解决这个问题?此外,图 2 的标题分为两行,而我希望它只在一行上。提前致谢
答案1
你的框架中存在更多问题:
- 图像太大...
- 轴标签我将与轴对齐
figure
我宁愿使用列和\captionof{figure}{<caption title>}
标题提供的标题,而不是环境中的两个小页面capt-of
母语:
\documentclass[xcolor=pdftex,t,11pt]{beamer}
\usepackage{tikz}
\usepackage{capt-of}% <-- added
\begin{document}
\begin{frame}
\frametitle{My presentation}
\framesubtitle{A theory}
\begin{itemize}
\item Consider the following two alternative situations:
\bigskip
\begin{columns}[t]
\column{0.45\linewidth}
\begin{tikzpicture}\small
% axis
\draw [->](-0.5,0) -- node[below] {Political Institutions} (4,0);
\draw [->](0,-0.5) -- node[above,sloped] {Economic Institutions} (0,4);
% curve
\clip (-0.5,-0.5) rectangle + (4.5,4.5);% <-- compensate influence of curve on image size
\draw [ultra thick, red] (0.2,3.5) to [out=280,in=260,looseness=3] (3.5,3.7);
\end{tikzpicture}
\captionof{figure}{$U$--shape relationship}
\column{0.45\linewidth}
\begin{tikzpicture}\small
% axis
\draw [->](-0.4,0) -- node[below] {Political Institutions} (4,0);
\draw [->](0,-0.4) -- node[above,sloped] {Economic Institutions} (0,4);
% curve
\clip (-0.5,-0.5) rectangle + (4.5,4.5);% <-- compensate influence of curve on image size
\draw [ultra thick, red] (2,1) to [out=360,in=260] (4,3.7);
\end{tikzpicture}
\captionof{figure}{Monotonically increasing relationship}
\end{columns}
\end{itemize}
\end{frame}
\end{document}
这使:
答案2
如果您不想使用capt-of
包而是使用小页面和图形,那么它的@Zarko 的答案(因此,不要接受它):
\documentclass[xcolor=pdftex,t,11pt]{beamer}
\usepackage{tikz}
%\usepackage{capt-of}% <-- added
\begin{document}
\begin{frame}
\frametitle{My presentation}
\framesubtitle{A theory}
\begin{itemize}
\item Consider the following two alternative situations:
\bigskip
\begin{minipage}[inner sep=0]{0.5\linewidth}
\begin{figure}
\begin{tikzpicture}\small
% axis
\draw [->](-0.5,0) -- node[below] {Political Institutions} (4,0);
\draw [->](0,-0.5) -- node[above,sloped] {Economic Institutions} (0,4);
% curve
\clip (-0.5,-0.5) rectangle + (4.5,4.5);% <-- compensate influence of curve on image size
\draw [ultra thick, red] (0.2,3.5) to [out=280,in=260,looseness=3] (3.5,3.7);
\end{tikzpicture}
\caption{$U$--shape relationship}
\end{figure}
\end{minipage}%
\begin{minipage}[inner sep=0]{0.5\linewidth}
\begin{figure}
\begin{tikzpicture}\small
% axis
\draw [->](-0.4,0) -- node[below] {Political Institutions} (4,0);
\draw [->](0,-0.4) -- node[above,sloped] {Economic Institutions} (0,4);
% curve
\clip (-0.5,-0.5) rectangle + (4.5,4.5);% <-- compensate influence of curve on image size
\draw [ultra thick, red] (2,1) to [out=360,in=260] (4,3.7);
\end{tikzpicture}
\caption{Monotonically increasing relationship}
\end{figure}
\end{minipage}
\end{itemize}
\end{frame}
\end{document}
输出:
PS:您可以使用@Zarko 建议[t]
的选项\begin{minipage}[t,inner sep=0]{0.5\linewidth}