0
votes

I'm exporting a presentation from an org file that includes a block of tikz code. This is my minimal working example:

#+TITLE: Beamer Question
#+AUTHOR: J. Doe
#+OPTIONS: H:2 toc:t
#+LATEX_CLASS: beamer
#+LATEX_CLASS_OPTIONS: [presentation, aspectratio=169]
#+LATEX_HEADER: \usepackage{graphicx}
#+BEAMER_THEME: Hannover
#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col)

* Introduction
** Problem
*** Normal text   
:PROPERTIES:   
:BEAMER_col: 0.4   
:END:   
This is how normal text looks; with sans serif font
*** Tikz image
:PROPERTIES:
:BEAMER_col: 0.6
:END:
#+begin_src latex :file tikz.pdf :packages '(("" "tikz")) :border 1pt :results raw   % Define block styles

  \begin{tikzpicture}[    text/.style={text width=5cm, align=center}]

  \node (n) [text] at (0,0) {But if I write text in a tikz picture, it uses the default Latex font (serif)};
  \end{tikzpicture}
#+end_src

Exporting this with M-x org-beamer-export-to-pdf produces this slide: enter image description here

My question is, how can I tell tikz to use the same font as the rest of the beamer presentation?

Things I've tried:

  • Search online. Found nothing

  • Export to latex file. The result is that orgmode executes the tikz code, produces a pdf (with the wrong font) and inserts the produced pdf as an image. The problem persists

EDIT: As requested, this is the latex code generated by orgmode

% Created 2020-03-29 dom. 09:45
% Intended LaTeX compiler: pdflatex
\documentclass[presentation, aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{graphicx}
\usetheme{Hannover}
\author{J. Doe}
\date{\today}
\title{Beamer Question}
\hypersetup{
 pdfauthor={J. Doe},
 pdftitle={Beamer Question},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.1 (Org mode 9.1.9)}, 
 pdflang={English}}
\begin{document}

\maketitle
\begin{frame}{Outline}
\tableofcontents
\end{frame}


\section{Introduction}
\label{sec:org689fb7a}
\begin{frame}[label={sec:org3b759e9}]{Problem}
\begin{columns}
\begin{column}{0.4\columnwidth}
This is how normal text looks; with sans serif font
\end{column}
\begin{column}{0.6\columnwidth}
\includegraphics[width=.9\linewidth]{tikz.pdf}
\end{column}
\end{columns}
\end{frame}
\end{document}
1
Can you show the resulting .tex code? Without seeing the code, this is just a guess: \tikzset{ font=\sffamily }samcarter_is_at_topanswers.xyz
@samcarter_is_at_topanswers.xyz I edited the questions to include the latex code. As you can see, orgmode executes the code tiks code and stores the results in a pdf file, and then inserts that pdf file in the resulting presentationjuanerasmoe

1 Answers

1
votes

The problem is that using a src block causes org to invoke LaTeX on that block and this does not inherit any settings from the document. What if you change begin_src...end_src to begin_export latex ... end_export?