1

I have several TikZ pictures, most are long files, which I would like to include in a Beamer presentation.

I am using adjustbox package to scale the tikzpicture and using the columns environment and \vspace{} to place the figure. For example,

\documentclass[t]{beamer}
\usepackage{multicol}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{graphicx}
% \usepackage{textpos} % para posicionar los frames en color
\usepackage{xcolor}
%%%---------------
\usetikzlibrary{calc}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric, arrows,positioning,shapes,arrows}
%%%%---------------------
\usepackage{adjustbox}
\setbeamercovered{transparent=7}
\begin{document}
        \begin{frame}[t]{Calidad}
            La calidad está relacionada con el ancho de banda y el retardo, e influye en la \textcolor{blue}{fiabilidad} y la \textcolor{blue}{\textbf{disponibilidad}}
            \begin{columns}[onlytextwidth]
                \begin{column}{0.48\textwidth} \vspace{.5cm}
                \begin{adjustbox}{max totalsize={1\textwidth}{1\textheight},left}
                     \begin{tikzpicture}%[font=\sffamily,]
                     % \draw[help lines] (0,-1) grid (8,6);
                     \draw[draw=black,fill=blue!10!green!30,semithick] (0,2) rectangle ++(3,1) node[yshift=+0.7cm,align=left] (A) {\small Falta de\\\small rendimiento};
                     \draw[draw=black,fill=yellow!20,semithick] (3,2) rectangle ++(1.8,1) node[pos=0.5] (B) {{\small 1}};
                     \draw[draw=black,fill=yellow!20,semithick] (4.8,2) rectangle ++(1,1)node[pos=0.5] {{\small 2}};
                     \draw[draw=black,fill=red!20,semithick] (5.8,2) rectangle ++(0.7,1) node (bel) [pos=0.5] {};
                    \draw[>-latex,semithick,red] ($(A)+(-0.4,-0.55)$) -- ($(A)+(0.4,-0.55)$);
                    \draw[>-latex,semithick,red] ($(B)+(0.65,0)$) --++ (0.55,0); 

                   \draw[black,latex-latex,] (0, 1.4) --++ (3,0) node [midway,above] {\small{Capacidad real}};
                   \draw[black,latex-latex,] (0, .5) --++ (6.5,0) node [midway,above] {\small{Capacidad total}};
                   \node[below,align=left] (i1) at (2,0) {\small 1. Incrementar la eficiencia  \\ \small 2. Mejorar la \only<2>{disponibilidad}\only<3->{\textbf{disponibilidad}}};
                   \draw[thin] (0,2) --++ (0,-1.6);
                   \draw[thin] (3,2) --++ (0,-0.7);
                   \draw[thin] (6.5,2) --++ (0,-1.6);

                   \draw[black,latex-] (5.3,3) --++ (120:1.2) node [above, align=left,xshift=0.5cm] {\small Indisponibilidad\\ \small evitable};
                   \draw[black,latex-] ($(bel) + (0,.5)$) --++ (90:0.3) node [above, align=left,xshift=0.5cm] {\small Indisponibilidad\\ \small inevitable};  
                 \end{tikzpicture}
            \end{adjustbox}
            \end{column}
            \column{0.49\textwidth}
            \begin{block}{GdR sirve para mejorar la disponibilidad}
                \begin{itemize}
                    \item Provisión de servicios
                    \item<+-> Evolución del rendimiento
                    \item<+-> Correlación de alarmas
                \end{itemize}
            \end{block}

        \end{columns}
    \end{frame}

\end{document}

I would like to make \input{file.tex} to make a cleaner code. Besides, I want to be able to scale down the tickzpicture of file.tex and easily test where to place the resulting image at the free space left in the slide.

pablo
  • 451
  • Please, merge your code fragment and extend than to an MWE (Minimal Working example), a small but complete document, which reproduce your problem. – Zarko Aug 21 '21 at 13:12
  • @Zarko Thank you. I have made changes in the example to be MWE. – pablo Aug 21 '21 at 15:37
  • You can try using the columns environment to split the slide into columns of selected widths, and place the table on one and the figure on the other. – vonbrand Aug 21 '21 at 19:45

1 Answers1

2

You can put all your tikz images in individual files (maybe in a different directory for reuse) to clean up the beamer code and also to optimize them one by one outside of the presentation.

This is the main.tex file.

\documentclass[t]{beamer}
\usepackage{multicol}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{graphicx}
% \usepackage{textpos} % para posicionar los frames en color
\usepackage{xcolor}
%%%---------------
\usetikzlibrary{calc}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric, arrows,positioning,shapes,arrows}
%%%%---------------------
\usepackage{adjustbox}
\setbeamercovered{transparent=7}
\begin{document}
    \begin{frame}[t]{Calidad}
        La calidad está relacionada con el ancho de banda y el retardo, e influye en la \textcolor{blue}{fiabilidad} y la \textcolor{blue}{\textbf{disponibilidad}}
        \begin{columns}[onlytextwidth]
            \begin{column}{0.48\textwidth} \vspace{.5cm}
                \begin{adjustbox}{max totalsize={1\textwidth}{1\textheight},left}                   
                    \input{firstfigure} %<<<<<<<<<<<<<<<<<<
                \end{adjustbox}
            \end{column}
            \begin{column}{0.49\textwidth}
            \begin{block}{GdR sirve para mejorar la disponibilidad}
                \begin{itemize}
                    \item Provisión de servicios
                    \item<+-> Evolución del rendimiento
                    \item<+-> Correlación de alarmas
                \end{itemize}
            \end{block}
            \end{column}
        \end{columns}
    \end{frame}

\end{document}

This is fistfigure.tex (in the same directory of main.tex)

%% file firstfigure.tex

\resizebox{!}{\linewidth}{% see https://tex.stackexchange.com/a/4340/161015

\begin{tikzpicture}%[font=\sffamily,] \draw[help lines] (0,-1) grid (8,6); \draw[draw=black,fill=blue!10!green!30,semithick] (0,2) rectangle ++(3,1) node[yshift=+0.7cm,align=left] (A) {\small Falta de\\small rendimiento}; \draw[draw=black,fill=yellow!20,semithick] (3,2) rectangle ++(1.8,1) node[pos=0.5] (B) {{\small 1}}; \draw[draw=black,fill=yellow!20,semithick] (4.8,2) rectangle ++(1,1)node[pos=0.5] {{\small 2}}; \draw[draw=black,fill=red!20,semithick] (5.8,2) rectangle ++(0.7,1) node (bel) [pos=0.5] {};

\draw[&gt;-latex,semithick,red] ($(A)+(-0.4,-0.55)$) -- ($(A)+(0.4,-0.55)$);
\draw[&gt;-latex,semithick,red] ($(B)+(0.65,0)$) --++ (0.55,0); 

\draw[black,latex-latex,] (0, 1.4) --++ (3,0) node [midway,above] {\small{Capacidad real}};
\draw[black,latex-latex,] (0, .5) --++ (6.5,0) node [midway,above] {\small{Capacidad total}};
\node[below,text width=5cm] (i1) at (3,0) {\small 1. Incrementar la eficiencia  \\ \small 2. Mejorar la \only&lt;2&gt;{disponibilidad}\only&lt;3&gt;{\textbf{disponibilidad}}};             

\draw[thin] (0,2) --++ (0,-1.6);
\draw[thin] (3,2) --++ (0,-0.7);
\draw[thin] (6.5,2) --++ (0,-1.6);

\draw[black,latex-] (5.3,3) --++ (120:1.2) node [above, align=left,xshift=0.5cm] {\small Indisponibilidad\\ \small evitable};
\draw[black,latex-] ($(bel) + (0,.5)$) --++ (90:0.3) node [above, align=left,xshift=0.5cm] {\small Indisponibilidad\\ \small inevitable};  

\end{tikzpicture} }

Note some changes:

From

\node[below,align=left] (i1) at (2,0) {\small 1. Incrementar la eficiencia  \\ \small 2. Mejorar la \only<2>{disponibilidad}\only<3->{\textbf{disponibilidad}}}; 

to

\node[below,text width=5cm] (i1) at (3,0) {\small 1. Incrementar la eficiencia  \\ \small 2. Mejorar la \only<2>{disponibilidad}\only<3>{\textbf{disponibilidad}}}; 

to improve the left alignment of the text in the three consecutive slides.

a

b

c

whereas before

d

e

One option for scaling is to use

\resizebox{<horizontal size>}{<vertical size>}{%
    \begin{tikzpicture}
\end{tikzpicture}

}

To keep the aspect ratio use ! in one of the dimensions.

\resizebox{!}{\linewidth}{ <content>}.

Using \resizebox{!}{0.7\linewidth}{%

x

NOTE \adjustbox is not used.

Use \begin{column}[T]{0.48\textwidth}

T aligns the tops of the first lines while the global default option is t .

    \documentclass[t]{beamer}
\usepackage{multicol}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{graphicx}
% \usepackage{textpos} % para posicionar los frames en color
\usepackage{xcolor}
%%%---------------
\usetikzlibrary{calc}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric, arrows,positioning,shapes,arrows}
%%%%---------------------
%\usepackage{adjustbox}% not used <<<<<
\setbeamercovered{transparent=7}
\begin{document}
    \begin{frame}[t]{Calidad}
        La calidad está relacionada con el ancho de banda y el retardo, e influye en la \textcolor{blue}{fiabilidad} y la \textcolor{blue}{\textbf{disponibilidad}}
        \begin{columns}[onlytextwidth]
            \begin{column}[T]{0.48\textwidth} \vspace{.2cm} %,<<<
                \centering %to center the figure horizontally if its width is less than column width
                \input{firstfigurescaled} %<<<<<<<<<<<<<<<<<<   \resizebox{!}{0.7\linewidth}{%
            \end{column}
            \begin{column}[T]{0.49\textwidth}
                \begin{block}{GdR sirve para mejorar la disponibilidad}
                    \begin{itemize}
                        \item Provisión de servicios
                        \item<+-> Evolución del rendimiento
                        \item<+-> Correlación de alarmas
                    \end{itemize}
                \end{block}
            \end{column}
        \end{columns}
    \end{frame}
\end{document}

To test the figures outside beamer a MWE will do.

\documentclass[12pt,a4paper,landscape]{article}

\usepackage{tikz} \usetikzlibrary{calc} \begin{document}

\input{firstfigurescaled} %\resizebox{!}{0.7\linewidth}{% 

\end{document}

Figure scale to 0.3\linewidth, centered in the column, top align.

z

Simon Dispa
  • 39,141
  • Thank you. How can I situate the figure out of the beamer column at any free space of the slide? – pablo Aug 22 '21 at 08:27