在投影仪幻灯片中定位和缩放长 TikZ 文件的最佳方法是什么?

在投影仪幻灯片中定位和缩放长 TikZ 文件的最佳方法是什么?

我有几个 TikZ 图片,大多数都是长文件,我想将它们包含在 Beamer 演示文稿中。

我正在使用adjustbox包来缩放 tikzpicture 并使用columns环境\vspace{}来放置图形。例如,

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

我想\input{file.tex}制作更简洁的代码。此外,我希望能够缩小 tickzpicturefile.tex并轻松测试将结果图像放置在幻灯片中剩余的可用空间的何处。

答案1

您可以将所有 tikz 图像放在单独的文件中(可能放在不同的目录中以供重复使用)以清理投影仪代码,并在演示文稿之外逐一优化它们。

这是main.tex文件。

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

这是fistfigure.tex(在 的同一目录中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[>-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,text width=5cm] (i1) at (3,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}
}

请注意一些变化:

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

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

改善三张连续幻灯片中文本的左对齐。

A

b

C

而之前

d

埃

扩展的一个选项是使用

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

为了保持纵横比,请使用!其中一个尺寸。

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

使用 \resizebox{!}{0.7\linewidth}{%

X

笔记 \adjustbox未使用。

使用\begin{column}[T]{0.48\textwidth}

T对齐第一行的顶部,而全局默认选项是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}

要测试投影机外部的图形,可以使用 MWE。

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

\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
    
    \input{firstfigurescaled} %\resizebox{!}{0.7\linewidth}{% 

\end{document}

图形比例为0.3\linewidth,位于列中央,顶部对齐。

是

相关内容