我的投影機簡報出現問題,我想將 2 個 Tikz 子圖插入一張投影機。為此,我使用了調整框,但出現了錯誤。
當我單獨放置每個 tikzpicture 時,沒有錯誤,儘管如此,當我嘗試將它們分成 2 個子圖時,錯誤出現了。
我正在尋找相關問題的答案。看來問題與圖形環境中的子浮點有關,但我沒有令人滿意的答案。
我的程式碼:
\documentclass[serif, xcolor={usenames,dvipsnames,table}]{beamer}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage{mathpazo}
\let\Tiny=\tiny
\mode<presentation> {
\usetheme{Malmoe}
\usecolortheme{beaver}
}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{enumerate}
\setbeamertemplate{section in head/foot}{\hfill\insertsectionhead}
\setbeamertemplate{section in head/foot shaded}{\color{red!40}\hfill\insertsectionhead}
\setbeamertemplate{section in toc}{\inserttocsectionnumber.~\inserttocsection}
\usepackage{hyperref}
\usepackage[alf]{abntex2cite}
\usepackage{tikz}
\usetikzlibrary{arrows}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=2pt] (char) {#1};}} %texto circulado
\usepackage{adjustbox}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{multicol}
%------------------------------------------------
\begin{document}
\begin{frame}{Eliminação de \textit{subtour}}
\begin{adjustbox}{max totalsize={1\textwidth}{.9\textheight},center}
\begin{figure}[htpb]
\centering
\subfigure[Eliminado pela variável $ \gamma $ e os conjuntos $ \Xi $]{
\begin{tikzpicture}[->, >=stealth', shorten >=1pt, auto, node distance=3cm, thick, main node/.style={circle, draw, font=\sffamily}]
\node[main node, label={above:Q1}] (1) {a};
\node[main node, label={above:R1}] (2) [right of=1] {c};
\node[main node, label={above:Q2}] (3) [right of=2] {d};
\node[main node, label={above:S2}] (4) [right of=3] {b};
\node[](aux1) at (5,-0.5) {};
\node[main node, label={left:P1}] (5) [below of=aux1] {g};
\node[](aux2) [below left of=1] {};
\node[main node, label={right:P3}] (6) [above right of=5] {e};
\node[main node, label={right:P2}] (7) [below right of=5] {f};
\path[every node/.style={font=\sffamily\small}]
(1) edge [right] node[left, below] {} (2)
(2) edge [right] node[left, below] {} (3)
(3) edge [right] node[left, below] {} (4)
(5) edge [right] node[left] {} (7)
(7) edge [right] node[right] {} (6)
(6) edge [red, right, line width=1.8pt] node[left, red] {} (5);
\end{tikzpicture}}
\subfigure[Eliminado pelas restrições \eqref{eq:sd-subtour-lmo}]{
\begin{tikzpicture}[->, >=stealth', shorten >=1pt, auto, node distance=3cm, thick, main node/.style={circle, draw, font=\sffamily}]
\node[main node, label={above:Q1}] (1) {a};
\node[main node, label={above:R2}] (2) [right of=1] {c};
\node[main node, label={above:Q2}] (3) [right of=2] {d};
\node[main node, label={above:S2}] (4) [right of=3] {b};
\node[](aux1) at (3,-0.5) {};
\node[main node, label={left:R1}] (5) [below of=aux1] {g};
\node[](aux2) [left of=5] {};
\node[main node, label={right:P3}] (6) [above right of=5] {e};
\node[main node, label={right:P2}] (7) [below right of=5] {f};
\path[every node/.style={font=\sffamily\small}]
(1) edge [right] node[left, below] {} (2)
(2) edge [right] node[left, below] {} (3)
(3) edge [right] node[left, below] {} (4)
(5) edge [right] node[left] {} (7)
(7) edge [right] node[right] {} (6)
(6) edge [right] node[left, red] {} (5);
\end{tikzpicture}}
\end{figure}
\end{adjustbox}
\end{frame}
\end{document}
謝謝你!
答案1
題外話,但很重要:
- 在其他套件之間,beamer 也會加載
graphicx
和hyperref
,因此再次加載它們是多餘的 - beamer 有自己的清單 (
itemize
,enumerate
) 來適應其具體情況。因此使用任何其他包來關注列表可能是脆弱的
您的問題似乎是由adjustbox
(和使用過時的subfigure
軟體包)引起的。我建議使用adjustwidth
包中的巨集來代替它changepage
。在下面的 MWE 中,我刪除了 MWE 中的所有混亂(未使用的程式碼片段),因此程式碼現在非常簡潔。我還替換了過時的subfigure package with
子標題`。
\documentclass[serif, xcolor={usenames,dvipsnames,table}]{beamer}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage{mathpazo}
\let\Tiny=\tiny
\mode<presentation> {
\usetheme{Malmoe}
\usecolortheme{beaver}
}
%\usepackage{graphicx} not needed
\usepackage{subcaption}
\usepackage{amssymb, mathtools}
%\usepackage{enumerate}
\setbeamertemplate{section in head/foot}{\hfill\insertsectionhead}
\setbeamertemplate{section in head/foot shaded}{\color{red!40}\hfill\insertsectionhead}
\setbeamertemplate{section in toc}{\inserttocsectionnumber.~\inserttocsection}
%\usepackage{hyperref}
\usepackage[alf]{abntex2cite}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, chains, positioning}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=2pt] (char) {#1};}} %texto circulado
\makeatletter
\tikzset{join reset/.code={\def\tikz@after@path{}}}
\makeatother
%\usepackage{adjustbox} better not use it
\usepackage{booktabs, multirow}
%\usepackage{multicol} not needed, beamer has own
\usepackage{changepage} % for more space fo image
%------------------------------------------------
\begin{document}
\begin{frame}
\frametitle{Eliminação de \textit{subtour}}
\begin{figure}
\tikzset{
shorten >=1pt,
node distance = 9mm and 5mm,
start chain = going right,
MN/.style = {% Main Node
circle, draw, semithick, font=\sffamily\scriptsize,
minimum size=3ex, inner sep=2pt,
on chain, join=by -{Straight Barb[]}},
}
\begin{adjustwidth}{-6mm}{-6mm}
\centering
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\node[MN, label=Q1] (1) {a};
\node[MN, label=R2] (2) {c};
\node[MN, label=Q2] (3) {d};
\node[MN, label=S2] (4) {b};
%
\node[MN, join reset,
label=left:P1,
below=of 4] (5) {g};
\node[MN, label=right:P3,
above right=of 5.south] (6) {e};
\node[MN, label=right:P2,
below right=of 5.north] (7) {f};
\draw[-{Straight Barb[]}] (7) -- (5);
\draw[red, line width=1pt,-{Straight Barb[]}] (5) -- (6);
\end{tikzpicture}
\caption{Eliminado pela variável $ \gamma $ e os conjuntos $ \Xi $}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}
\node[MN, label=Q1] (1) {a};
\node[MN, label=R2] (2) {c};
\node[MN, label=Q2] (3) {d};
\node[MN, label=S2] (4) {b};
%
\node[MN, join reset,
label=left:P1,
below=of 4] (5) {g};
\node[MN, label=right:R1,
above right=of 5.south] (6) {e};
\node[MN, label=right:P2,
below right=of 5.north] (7) {f};
\draw[-{Straight Barb[]}] (7) -- (5);
\end{tikzpicture}
\caption{Eliminado pelas restrições \eqref{eq:sd-subtour-lmo}}
\end{subfigure}
\end{adjustwidth}
\end{figure}
\end{frame}
\end{document}
我希望該圖像接近您想要的:)