0

I am trying to put 2 boxes of similar height under a figure on a beamer template. After many suggestions, a user advised me to use hf-tikz. But while I use it for equations under a figure it keeps boxing the images above instead of the equations.

However by removing the images, it plots the required result : Is it something related to the use of figure ?

Thank you,

enter image description here

\documentclass{beamer}

\usepackage[beamer,customcolors,nofill,norndcorners]{hf-tikz}
\hfsetbordercolor{blue!50!black}

\begin{document}

\begin{frame}{Méthode de mesure}

    \begin{figure}[!ht]
    \centering
    \subfloat[\centering Cas à une interface ]{{\includegraphics[width=0.45 \linewidth ]{pic/FCD1.png} }}%
    \qquad
    \subfloat[\centering Cas pour n interfaces]{{\includegraphics[width=0.45 \linewidth]{pic/FCD2.png} }}%
    \caption{2 La démodulation en motif de Schlieren}%
    \label{fig:example}%
    \end{figure}
    
$\displaystyle\tikzmarkin<1->{a}(0.1,-0.4)(-0.1,0.6) 
\nabla \zeta_0 = -\frac{\delta r}{h^{*}}  \ \text{avec :}\ \frac{1}{h^{*}} = \frac{1}{\alpha h_p} - \frac{1}{H}
\tikzmarkend{a}
$
\hfill
$\displaystyle\tikzmarkin<1->{b}(0.1,-0.4)(-0.1,0.6) 
\alpha = 1 - \frac{n}{n'} \ \text{et :} \ h_p = h_0
\tikzmarkend{b}
$
\end{frame}
\end{document}

EDIT : packages used :

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

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

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



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

%%%%% GITHUB %%%%%%%%
    \usepackage{YTU}

%%%%%% 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,
}

%%%%%% VIDEO %%%%%%%%%%%%%%
\usepackage{multimedia}

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

\hfsetbordercolor{blue!50!black}

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

\pgfmathdeclarefunction{gaussian}{2}
{%
    \pgfmathparse{(1/(#1 * sqrt(2 * pi))) * exp((-1 / 2) * (((x - #2)/#1) ^ 2))}%
}
\pgfmathsetmacro{\mean}{7}
\pgfmathsetmacro{\std}{0.3}
\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{arrows.meta,
                patterns.meta
                }

1 Answer 1

2

The problem is unrelated to the boxes, the subcaption package is missing.

This will be shown to by an error in the log file. After an error, latex only recovers enough to syntax check the rest of the document, not necessarily producing reasonable output.

Other comments:

  • beamer does not have a floating mechanism, it makes no sense to specify floating specifier like [!ht]
  • beamer automatically centres the content of a figure environment, \centering is not necessary
\documentclass{beamer}

\usepackage[beamer,customcolors,nofill,norndcorners]{hf-tikz}
\hfsetbordercolor{blue!50!black}
\usepackage{subcaption}

\begin{document}

\begin{frame}{Méthode de mesure}


    \begin{figure}
    \subfloat[Cas à une interface ]{\includegraphics[width=0.45 \linewidth]{example-image-duck}}%
    \hfill
    \subfloat[Cas pour n interfaces]{\includegraphics[width=0.45 \linewidth]{example-image-duck}}%
    \caption{2 La démodulation en motif de Schlieren}%
    \label{fig:example}%
    \end{figure}
    
$\displaystyle\tikzmarkin<1->{a}(0.1,-0.4)(-0.1,0.6) 
\nabla \zeta_0 = -\frac{\delta r}{h^{*}}  \ \text{avec :}\ \frac{1}{h^{*}} = \frac{1}{\alpha h_p} - \frac{1}{H}
\tikzmarkend{a}
$
\hfill
$\displaystyle\tikzmarkin<1->{b}(0.1,-0.4)(-0.1,0.6) 
\alpha = 1 - \frac{n}{n'} \ \text{et :} \ h_p = h_0
\tikzmarkend{b}
$
\end{frame}
\end{document}

enter image description here

7
  • Thank you for your answer : but I am still having the same issue... I tried to add subcaption and then subfigure but it didn't work. Can I edit my post to put the packages that I use for the template ? Thank you
    – Waxler
    Sep 14, 2022 at 11:22
  • With your packages it works fine i.stack.imgur.com/eIl2g.png Did you compile two times? Can you make a compilable minimal working example that reproduces your problem? Not several code blocks we have to puzzle together... Also show your .log file so we can see if there are more errors in your document. Sep 14, 2022 at 11:26
  • It works now : for some reason it was required to compile more than 2 times... But this is the required result so thank you again.
    – Waxler
    Sep 14, 2022 at 11:39
  • @Wiss You're welcome! Sep 14, 2022 at 11:40
  • 1
    @Wiss Yes, it is. That's one of the reasons I kept suggesting this package instead of your other boxes Sep 14, 2022 at 11:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .