2 Tikzpicktures, 2 subfiguras en 1 cuadro de ajuste, 1 diapositiva y algunos errores

2 Tikzpicktures, 2 subfiguras en 1 cuadro de ajuste, 1 diapositiva y algunos errores

Tengo problemas con mi presentación de proyector. Me gustaría insertar 2 subfiguras de Tikz en una sola diapositiva. Para eso estoy usando un cuadro de ajuste pero tengo errores.

Cuando pongo cada tikzpicture por separado no hay ningún error, sin embargo, cuando intento colocarlos en 2 subfiguras, aparece el error.

Estoy buscando respuestas a problemas relacionados. Parece que el problema está relacionado con subflotadores en el entorno de la figura, pero no tengo una respuesta satisfactoria.

Mi código:

\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}

¡Gracias!

Respuesta1

Fuera de tema, pero importante:

  • entre otros paquetes, Beamer también carga graphicxy hyperref, por lo que sobra cargarlos nuevamente.
  • Beamer tiene su propia lista ( itemize, enumerate) adoptada para su específico. en consecuencia, use cualquier otro paquete que la lista de preocupaciones puede ser frágil

Su problema parece ser causado por adjustbox(y el uso de subfigureun paquete obsoleto). En lugar de eso, sugiero usar la macro adjustwidthdel paquete changepage. En MWE a continuación, elimino todo el desorden en su MWE (fragmentos de código no usados), por lo que el código ahora es muy conciso. También reemplazo subfigure package withel subtítulo obsoleto`.

\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}

ingrese la descripción de la imagen aquí

Espero que la imagen se acerque a lo que te gusta tener :)

información relacionada