在 Beamer 模板上调整 tikz 绘图下的 2 幅图像

在 Beamer 模板上调整 tikz 绘图下的 2 幅图像

我正在尝试\tikzfigure在 beamer 模板中显示 2 幅图像,但调整似乎非常错误。似乎 tikz 绘图的高度太大,无法与同一模板上的图形相适应:我不知道如何在不影响内部内容的情况下调整此图形的缩放比例。(我尝试过这个\scale选项,但不太美观)理想情况下,我希望保持一种“固定”的纵横比,并稍微降低 tikz 绘图的高度,以便为下面的图像腾出一些空间,但我无法做到这一点……

是否有一种优雅的方式可以在一帧中显示所有这些内容?

感谢您的帮助,

\documentclass[t]{beamer}

%%%%%% ENCODAGE %%%%%%%%%%%
\usepackage[utf8]{inputenc}

%%%%%% TIKZ %%%%%%%%%%%%%%%
\usepackage[beamer,customcolors,norndcorners]{hf-tikz}

%%%%%% OTHERS %%%%%%%%%%%%%
\usepackage{booktabs,calligra}
\usepackage{listings,stackengine}



\author{XXX}
\title{XXX}
\subtitle{XXX}
\institute [XXX] {XXX \\ XXX}
\date{\today}

%%%%%% DEFINITIONS %%%%%%%%%
\def\cmd#1{\texttt{\color{red}\footnotesize $\backslash$#1}}
\def\env#1{\texttt{\color{blue}\footnotesize #1}}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}
\definecolor{halfgray}{gray}{0.55}

\lstset{
    basicstyle=\ttfamily\small,
    keywordstyle=\bfseries\color{deepblue},
    emphstyle=\ttfamily\color{deepred},    % Custom highlighting style
    stringstyle=\color{deepgreen},
    numbers=left,
    numberstyle=\small\color{halfgray},
    rulesepcolor=\color{red!20!green!20!blue!20},
    frame=shadowbox,
}

%%%%%% BOX %%%%%%%%%%%%%%%%
\usepackage{fancybox}
\usepackage{varwidth}
\usepackage{subcaption}

\hfsetbordercolor{blue!50!black}

%%%%%% PGFPLOTS %%%%%%%%%%%%
\usepackage[export]{adjustbox}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\definecolor{BgYellow}{HTML}{FFF59C}
\definecolor{FrameYellow}{HTML}{F7A600}
\usepackage{pgf, tikz, adjustbox}
\usetikzlibrary{spy}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns, matrix, positioning}
\usetikzlibrary{decorations.markings, arrows.meta,
                patterns.meta
                }


\usepackage[most]{tcolorbox}
\tcbset{highlight math style={enhanced,colframe=red,colback=red!10!white,boxsep=0pt,sharp corners,
equal height group=C,
minimum for equal height group=C:1.5cm,
valign=center,
}}


\begin{document}


\begin{frame}{L'approche physique}
\begin{figure}
\begin{tikzpicture}[
declare function={
gauss(\x)=3*exp(-(\x/3)^2);
}, scale = 0.6]
\fill[cyan!20] plot[domain=-8:8, samples=100] (\x, {gauss(\x)});
\filldraw[fill=pink!20, very thick] plot[domain=-8:8, samples=100] (\x, {gauss(\x)}) -- plot[domain=8:-8, samples=100] (\x, {gauss(\x)+0.6}) -- cycle;
\path[
decoration={
  markings,
  mark=between positions 0 and 1 step 1/10 with {\draw[dashed,thick, -{Triangle}] (0,1.2) -- (0,0.05);}},
decorate,
] plot[domain=-8:8, samples=100] (\x, {gauss(\x)});
\path[fill=cyan!20] (-0.85,-3) -- (-0.85,0) -- (0.85,0) -- (0.85,-3) -- (-0.85,-3);

% Origine du domaine
\fill (0,0) circle[radius=2pt]; 
\node[below left, scale = 0.75] at (0,0) {$0$};

% Caractéristiques physiques du fluide
\node[right] at (-2,1.5) {$(\rho,\mu)$};
\node[right,scale=1.25] at (-8.5,2.5) {$P_T$};

% Axes
\draw[dotted,-stealth,thick] (0, 0) -- (0,  6) node[right] {$\underline{e}_z$}; % z-axis
\draw[dotted,-stealth,thick] (0, 0) -- ( 9,0) node[above] {$\underline{e}_x$}; % x-axis

% Grandeurs de longueur
\draw[red, dashed, thick, Stealth-Stealth] (1,0) --node[fill=cyan!20]{$H$} (1,{gauss(1)});
\draw[red, dashed, thick, Stealth-Stealth] (0,-0.4275) --node[fill=white]{$R$} (6.5,-0.4275);
\draw [yshift=-0.6cm, -stealth](0,-2) -- node [fill=cyan!20] {$Q(t)$} (0,0);

\end{tikzpicture}
\end{figure}

    \begin{figure}
    \subfloat[\centering Laccolithe typique ]{{\includegraphics[width=0.3 \linewidth ]{example-image} }}%
    \qquad
    \subfloat[\centering Structure interne]{{\includegraphics[width=0.3 \linewidth]{example-image} }}%
    \caption{Le phénomène géologique}%
    \label{fig:example}%
    \end{figure}
\end{frame}


\end{document}

在此处输入图片描述

答案1

此代码将两个图形插入另一个图形中tikzpicture,以便将它们相对于框架定位。

A

添加\setbeamertemplate{caption}[numbered]有编号的数字。

yshift上面的 tikzpicture 可以使用(yshift= -2.5cm在示例中)垂直定位。

\documentclass[t]{beamer}

%%%%%% ENCODAGE %%%%%%%%%%%
\usepackage[utf8]{inputenc}

\usepackage[beamer,customcolors,norndcorners]{hf-tikz}

\setbeamertemplate{caption}[numbered]% added <<<<<<<<<<<<<<<

%%%%%% OTHERS %%%%%%%%%%%%%
\usepackage{booktabs,calligra}
\usepackage{listings,stackengine}

\usepackage{caption}

\author{XXX}
\title{XXX}
\subtitle{XXX}
\institute [XXX] {XXX \\ XXX}
\date{\today}

%%%%%% DEFINITIONS %%%%%%%%%
\def\cmd#1{\texttt{\color{red}\footnotesize $\backslash$#1}}
\def\env#1{\texttt{\color{blue}\footnotesize #1}}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}
\definecolor{halfgray}{gray}{0.55}

\lstset{
    basicstyle=\ttfamily\small,
    keywordstyle=\bfseries\color{deepblue},
    emphstyle=\ttfamily\color{deepred},    % Custom highlighting style
    stringstyle=\color{deepgreen},
    numbers=left,
    numberstyle=\small\color{halfgray},
    rulesepcolor=\color{red!20!green!20!blue!20},
    frame=shadowbox,
}

%%%%%% BOX %%%%%%%%%%%%%%%%
\usepackage{fancybox}
\usepackage{varwidth}
\usepackage{subcaption}

\hfsetbordercolor{blue!50!black}

%%%%%% PGFPLOTS %%%%%%%%%%%%
\usepackage[export]{adjustbox}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
\definecolor{BgYellow}{HTML}{FFF59C}
\definecolor{FrameYellow}{HTML}{F7A600}
\usepackage{pgf, tikz, adjustbox}
\usetikzlibrary{spy}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns, matrix, positioning}
\usetikzlibrary{decorations.markings, arrows.meta,
    patterns.meta
}


\usepackage[most]{tcolorbox}
\tcbset{highlight math style={enhanced,colframe=red,colback=red!10!white,boxsep=0pt,sharp corners,
        equal height group=C,
        minimum for equal height group=C:1.5cm,
        valign=center,
}}


\begin{document}    
    
\begin{frame}{L'approche physique}
    \begin{figure}
        \begin{tikzpicture}[
            remember picture, overlay, yshift=-2.5cm,
            declare function={
                gauss(\x)=3*exp(-(\x/3)^2);
            }, scale = 0.6]
            \fill[cyan!20] plot[domain=-8:8, samples=100] (\x, {gauss(\x)});
            \filldraw[fill=pink!20, very thick] plot[domain=-8:8, samples=100] (\x, {gauss(\x)}) -- plot[domain=8:-8, samples=100] (\x, {gauss(\x)+0.6}) -- cycle;
            \path[
            decoration={
                markings,
                mark=between positions 0 and 1 step 1/10 with {\draw[dashed,thick, -{Triangle}] (0,1.2) -- (0,0.05);}},
            decorate,
            ]           
        plot[domain=-8:8, samples=100] (\x, {gauss(\x)});
            \path[fill=cyan!20] (-0.85,-3) -- (-0.85,0) -- (0.85,0) -- (0.85,-3) -- (-0.85,-3);
            
            % Origine du domaine
            \fill (0,0) circle[radius=2pt]; 
            \node[below left, scale = 0.75] at (0,0) {$0$};
            
            % Caractéristiques physiques du fluide
            \node[right] at (-2,1.5) {$(\rho,\mu)$};
            \node[right,scale=1.25] at (-8.5,2.5) {$P_T$};
            
            % Axes
            \draw[dotted,-stealth,thick] (0, 0) -- (0,  6) node[right] {$\underline{e}_z$}; % z-axis
            \draw[dotted,-stealth,thick] (0, 0) -- ( 9,0) node[above] {$\underline{e}_x$}; % x-axis
            
            % Grandeurs de longueur
            \draw[red, dashed, thick, Stealth-Stealth] (1,0) --node[fill=cyan!20]{$H$} (1,{gauss(1)});
            \draw[red, dashed, thick, Stealth-Stealth] (0,-0.4275) --node[fill=white]{$R$} (6.5,-0.4275);
            \draw [yshift=-0.6cm, -stealth](0,-2) -- node (QT)[fill=cyan!20] {$Q(t)$} (0,0);
        \end{tikzpicture}
    \vspace*{6.8cm}
    \caption{Le phénomène géologique}%
    \label{fig:example}%        
    \end{figure}

    
    \begin{figure}%changed <<<<<<<<<<<<<<<<<<<<<<<<<<
        \begin{tikzpicture}[remember picture, overlay,] 
                \node[above=1.0cm, anchor= south west,xshift= 0.5cm] at (current page.south west) {
                \subfloat[Laccolithe typique]{{\includegraphics[width=0.3\linewidth ]{example-image-a} }}
            };
                \node[above=1.0cm, anchor= south east,xshift= -0.5cm] at (current page.south east){
                \subfloat[Structure interne]{{\includegraphics[width=0.3\linewidth ]{example-image-b} }}
            };      
        \end{tikzpicture}   
    \end{figure}    
    \end{frame}     
    
\end{document}

标题也可以相对于框架定位。例如,添加到上部tikzpicture

\node [above] at (current page.south) {         
             \parbox{\textwidth}{\captionof{figure}{Le phénomène géologique}
                \label{fig:exampl}
    }}; 
            

相关内容