R Markdown (beamer) - how to create 2 columns
Asked Answered
L

1

1

I am trying to create a presentation using RMarkdown beamer. I want a slide to have 2 columns and this is what I have so far:

---
title: title

author: name
        
date: date

output:
  beamer_presentation:
    theme: Szeged
    slide_level: 2
    includes:
      in_header: header.tex
    keep_tex: true

linkcolor: false
---
    
## TEST

\footnotesize
\justify
:::::::::::::: {.columns}
::: {.column}
- I will write something here tex text text tex text text tex text text
:::
::: {.column}
- And then something here tex text text tex text text tex text text tex text text
:::
::::::::::::::

The header.tex's content is:

\definecolor{mycolorlightblue}{RGB}{103,153,200}
\definecolor{mycolordarkblue}{RGB}{0,70,127}
% add packages
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{tcolorbox}
\usepackage{ragged2e}
% remove 2nd section from header
\makeatletter
\beamer@theme@subsectionfalse
\makeatother
% change colour of lines
\setbeamercolor{separation line}{bg=mycolorlightblue}
% text title
\setbeamercolor{title}{fg=mycolordarkblue}
\setbeamercolor{frametitle}{fg=mycolordarkblue}
% text colour
\setbeamercolor{frametitle}{fg=mycolordarkblue}
% item colour
\setbeamercolor{structure}{fg=mycolordarkblue}
% define colour text
% \usebeamerfont{section title}\color{blue!70!green}\insertsection\par
% no header or footer on first page
\thispagestyle{empty}
% remove title slides at beginning of sections
\AtBeginSection{}
% add page counter to the footer
\setbeamertemplate{footline}[frame number]
% logo of my university
\titlegraphic{%
  \begin{picture}(0,0)
    \put(155,0){\makebox(0,0)[rt]{\includegraphics[]{ALL-ICONS.png}}}
  \end{picture}}

This is the result I am seeing, almost perfect, but the 2nd column starts slight below the first one, as shown below, do you understand why?

enter image description here

correspondent .tex file to the .rmd:

\begin{frame}{TEST}
\protect\hypertarget{test}{}

\footnotesize
\justify

\begin{columns}[T]
\begin{column}{0.48\textwidth}
\begin{itemize}
\tightlist
\item
  I will write something here text text text text text text text text
  text text text text text text text
\end{itemize}
\end{column}

\begin{column}{0.48\textwidth}
\begin{itemize}
\tightlist
\item
  And then something here text text text text text text text text text
  text text text text text text
\end{itemize}
\end{column}
\end{columns}

\end{frame}
Lamoreaux answered 7/2, 2021 at 16:59 Comment(4)
Can you post the intermediate .tex file?Proboscis
Many thanks Sam. I've just edited my question with .tex content as requested. Do you have any idea of what might be happening?Lamoreaux
Thanks to the option keep_tex: true, there should be a .tex with the same name as your .rmd file. Can you post it, so we see the code used for the columns?Proboscis
Many thanks Sam. Ive just edited my question to include the code part of the .tex file that is used for the columns.Lamoreaux
P
1

The problem is the \justify, it should be \justifying instead (but at the position you use it, it won't have any effect on the text in the columns anyway, so you could also just remove it ...)

---
title: title

author: name
        
date: date

output:
  beamer_presentation:
    theme: Szeged
    slide_level: 2
    includes:
      in_header: header.tex
    keep_tex: true
---
    
## TEST

\footnotesize
:::::::::::::: {.columns}
::: {.column}
- I will write something here tex text text tex text text tex text text
:::
::: {.column}
- And then something here tex text text tex text text tex text text tex text text
:::
::::::::::::::

enter image description here

Proboscis answered 8/2, 2021 at 11:41 Comment(4)
@samcarter_is_at_topanswers.xyz: what is the reason for of :::::::::::::: {.columns} followed by ::: {.column}? Would ::: columns and then :::: column also. lead to the same set of columns? (Or are there any differences, e.g., of content alignment?Fairley
@Fairley I have no ideaProboscis
@Proboscis By chance, do you know if I can pass further arguments to make adjustments to vertical alignment? Maybe similar to width {.column width=30%}?Fairley
@Fairley You can use ::: {.column width="30%"}Proboscis

© 2022 - 2024 — McMap. All rights reserved.