1

I am trying to adjust some elements of a frame and I keep having some problems that I don't understand.

I am displaying 2 boxes of equations by using \columns to split the frame and add some titles and I use \tikzmarkin to display properly the boxes with imposed (identical) dimensions.

I don't understand why :

  • The "titles" associated to each column are in different position.
  • The margin is not respected on the right side so it's not symmetrical (I thought that \columns doest it automatically ?)
  • Also how can I impose the boxes to be aligned on the centerline of the frame ? (Doesn't it supposed to be done by \columns[c] ?)

Thank you in advance for your help,

\documentclass[t]{beamer}

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

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

%%%%%% OTHERS %%%%%%%%%%%%%
\usepackage{booktabs,calligra}
\usepackage{listings,stackengine}
\def\doubleunderline#1{\underline{\underline{#1}}}


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

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

%%%%%% 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}{Formalisme physique}
\begin{columns}[c]
\begin{column}{.5\linewidth}
    \centering {\color{deepblue} Problème de Stokes}
    \vskip0.2cm
    \begin{equation*}
    \tikzmarkin<1->[set fill color=white, set border color=blue!50!black]{a}(0.1,-1.65)(-0.1,1.75) 
  \left\{
      \begin{aligned}
        0 &= - \frac{\partial P}{\partial r} + \mu \frac{\partial^2 u}{\partial z^2}    \\
        0 &= -\frac{\partial P}{\partial z} - \rho g    \\
        0 &= \frac{\partial {u}}{\partial {r}} + \frac{{u}}{{r}} + \frac{\partial {w}}{\partial {z}}\\
     \end{aligned}
    \right.
    \tikzmarkend{a}
    \end{equation*}
\end{column}
\begin{column}{.5\linewidth}
    \centering {\color{deepblue} Conditions limites}
    \vskip0.2cm
    \begin{equation*}
    \tikzmarkin<1->[set fill color=white, set border color=blue!50!black]{b}(0.1,-1.65)(-0.1,1.75) 
  \left\{
      \begin{aligned}
        {w}({z} = {h}) &= \frac{\partial {h}}{\partial {t}} + {u} \frac{\partial {h}}{\partial {r}}   \\
        {p}(z = {h}) &= {D} \left( \Delta^{2}_{{r}} {h}\right) + \rho g h+{P_0}  \\
        \doubleunderline{\sigma} \cdot \underline{n} &= - P_T \cdot \underline{n}\\
     \end{aligned}
    \right.
    \tikzmarkend{b}
    \end{equation*}
\end{column}
\end{columns}
\end{frame}



\end{document}

enter image description here

1 Answer 1

3
  • The "titles" associated to each column are in different position.

Due to the different space between your titles and the boxes, your columns had different heights. As you are using [c]entred columns, the titles thus won't be at the same height

enter image description here

  • The margin is not respected on the right side so it's not symmetrical (I thought that \columns doest it automatically ?)

The margins will adopt automatically to the width of the columns, but if put content into the column which is much wider than the width of the column, it will stick out. Latex will inform you about the overfull hbox in the log file

  • Also how can I impose the boxes to be aligned on the centerline of the frame ? (Doesn't it supposed to be done by \columns[c] ?)

centred columns will align the columns centred with respect to each other. If you want the content to be in the centre of the frame, use a [c]entre aligned frame.

enter image description here


To warp a whole equations inside a box (as opposed to only parts within the equation as in your previous questions), I suggest to use a tcolorbox:

\documentclass[t]{beamer}

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

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

%%%%%% OTHERS %%%%%%%%%%%%%
\usepackage{booktabs,calligra}
\usepackage{listings,stackengine}
\def\doubleunderline#1{\underline{\underline{#1}}}


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

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

%%%%%% 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=blue!50!black,colback=bg,boxsep=0pt,sharp corners,
equal height group=C,
minimum for equal height group=C:1.5cm,
valign=center,
}}



\begin{document}

\begin{frame}[c]
\frametitle{Formalisme physique}
\begin{columns}
\begin{column}{.41\linewidth}
    \centering {\color{deepblue} Problème de Stokes}
\begin{tcolorbox}[ams equation*,colback=bg,colframe=blue!50!black,equal height group=C,valign=center,top=-.7\baselineskip]
  \left\{
      \begin{aligned}
        0 &= - \frac{\partial P}{\partial r} + \mu \frac{\partial^2 u}{\partial z^2}    \\
        0 &= -\frac{\partial P}{\partial z} - \rho g    \\
        0 &= \frac{\partial {u}}{\partial {r}} + \frac{{u}}{{r}} + \frac{\partial {w}}{\partial {z}}\\
     \end{aligned}
    \right.
    \end{tcolorbox}
    
\end{column}
\begin{column}{.65\linewidth}
    \centering {\color{deepblue} Conditions limites}
\begin{tcolorbox}[ams equation*,colback=bg,colframe=blue!50!black,equal height group=C,valign=center,top=-.7\baselineskip]
  \left\{
      \begin{aligned}
        {w}({z} = {h}) &= \frac{\partial {h}}{\partial {t}} + {u} \frac{\partial {h}}{\partial {r}}   \\
        {p}(z = {h}) &= {D} \left( \Delta^{2}_{{r}} {h}\right) + \rho g h+{P_0}  \\
        \doubleunderline{\sigma} \cdot \underline{n} &= - P_T \cdot \underline{n}\\
     \end{aligned}
    \right.
    \end{tcolorbox}
    
\end{column}
\end{columns}
\end{frame}



\end{document}

enter image description here

4
  • Thank you for your answer : but I still didn't get the difference "height" issue because I think that I am specifying the same distance between the top of columns and the box drawn inside by imposing \vskip0.2cm for both of them. Is it the wrong way to do it ? Also, there is a strange issue related to the correction that you provided because it seems to interfere with an other slide of my original document : I will edit my post to show you this issue. Thank you for your kind help.
    – Wiss
    Sep 29 at 7:50
  • 1
    If you already use the name C for another equal height group, choose some other name for the new boxes. Sep 29 at 7:57
  • Thank you : this is what happens when copying/pasting directly. Also, It may seem dumb to you but I will be grateful if you could just explain again this part of your answer : "Due to the different space between your titles and the boxes, your columns had different heights." Why is there different spacing since I am imposing a fixed distance for both columns \vskip0.2cm ? Thanks
    – Wiss
    Sep 29 at 8:12
  • The equations themselves have different heights. \tikzmarkin is meant to annotate parts of equations without influencing their position with respect to other parts of the equation. Compile without the boxes and you'll see the exact same position of the equations. Sep 29 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.