Emacs org-mode latex export doesnt export bibliography - emacs

I tried to export a document with orgmode to a pdf. Unfortunately it doesnt export the citations. I make a minimal example of and export it. Same Problem. So maybe i think there is a Problem with the \printbibliography.
org file
# Latexheader
#+LATEX_HEADER: \documentclass[12pt]{article}
#+LATEX_HEADER: \usepackage[a4paper, left=4cm, right=2cm, top=3cm, bottom=3cm,margin=2cm]{geometry}
#+LATEX_HEADER: \usepackage{biblatex}
# Bibliography
#+bibliography: ../lit.bib
#+cite_export: csl <PATH>/ieee.csl
# Document
* Heading
Test [cite:#all]
#+print_bibliography:
lit.bib
#inproceedings{all,
title={papertitle},
author={paperauthor},
booktitle={PAPER3000},
year={2002}
}
tex file
% Created 2022-09-20 Di 20:59
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{minted}
\documentclass[12pt]{article}
\usepackage[a4paper, left=4cm, right=2cm, top=3cm, bottom=3cm,margin=2cm]{geometry}
\author{xdobx}
\date{\today}
\title{}
\hypersetup{
pdfauthor={xdobx},
pdftitle={},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 28.1 (Org mode 9.5.2)},
pdflang={English}}
\makeatletter
\newcommand{\citeprocitem}[2]{\hyper#linkstart{cite}{citeproc_bib_item_#1}#2\hyper#linkend}
\makeatother
\usepackage[notquote]{hanging}
\begin{document}
\tableofcontents
\section{Heading}
\label{sec:org89209e9}
Test TEST [1]
\printbibliography
\end{document}
The output is unsatisfying.
PDF without bibliography
I tried different ways:
wrap \printbibliography in a #+begin_latex/#+end_latex block.
install citeproc-org: but this only brought more errors
add biblatex with #+LATEX_HEADER: \usepackage{biblatex} as #samcarter_is_at_topanswers.xyz suggest
: correct export of header, but no difference in .pdf
How can i get a nice IEEE-Style formatted bibliography at the end of my document?
Edit I
rewrite \printbibliography to #+print_bibliography: and it works in the minimal example, if i tried it at the original document it only works if i don't use #+cite_export: csl <PATH>/ieee.csl.
If i use it, i get a error: unknown bibliography extension: nil
Edit II
the rewrite from Edit I works, i just forget a #+BIBLIOGRAPHY: here from citeproc-org somewhere in the big file.

The correct solution is to load \biblatex with
#+LATEX_HEADER: \usepackage{biblatex} and insert bibliography with#+print_bibliography: where you want. Correct minimal example .org :
# Latexheader
#+LATEX_HEADER: \documentclass[12pt]{article}
#+LATEX_HEADER: \usepackage[a4paper, left=4cm, right=2cm, top=3cm, bottom=3cm,margin=2cm]{geometry}
#+LATEX_HEADER: \usepackage{biblatex}
# Bibliography
#+bibliography: ../lit.bib
#+cite_export: csl <PATH>/ieee.csl
# Document
* Heading
Test [cite:#all]
#+print_bibliography:

Related

Using a Bib file on VSCode with Latex Workshop enabled

I am using VScode (macOS operating system) as a pseudo overleaf (trying to prevent connectivity issues). I am using a revtex template and want to use a bib file to hold all my references. For some reason the bib file is not parsing. When I save the bibtex file, the references I've entered just disappear.
This is the error that I get when I save my file:
"Bibtex parser failed with error: Expected ",", "=", "\r\n", [ \t\n], or [^#={}", \t\r\n] but "}" found."
I want to set up my VScode like overleaf, so if anyone has any simple solutions please do comment!
Below is my code
\documentclass[a4paper, amsfonts, amssymb, amsmath, reprint, showkeys, nofootinbib, twoside, aps, pra]{revtex4-1}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[colorinlistoftodos, color=green!40, prependcaption]{todonotes}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage[left=23mm,right=13mm,top=35mm,columnsep=15pt]{geometry}
\usepackage{adjustbox}
\usepackage{placeins}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{csquotes}
% \usepackage{biblatex}
\usepackage[pdftex, pdftitle={Article}, pdfauthor={Author}]{hyperref} % For hyperlinks in the PDF
\def\bibsection{\section*{\refname}} % removes ugly line above bibliography
%\setlength{\marginparwidth}{2.5cm}
% \bibliographystyle{apsrev4-1}
% \addbibresource{LitReviewNotes.bib}
\begin{document}

How to export inline quotations from emacs org mode to latex csquotes syntax?

I would like to export inline quotations in an org-document to \enquote{} commands. The csquotes package then ensures French quotation marks « » are used in the resulting pdf document.
I am well aware this question has been asked before here - and that solutions have been suggested by #Jonathan Leech-Pepin and #Christophe Poile. I tried all solutions suggested, without success. I would like to avoid (1) hardcoding the correct quotation marks or (2) using the latex command in my org document. OSX 10.15.5, emacs 26.2, org 9.2.5.
Org document header:
#+Title: GS
#+AUTHOR: HDV
#+SEQ_TODO:
#+TAGS:
#+STARTUP: indent
#+LANGUAGE: fr
#+LaTeX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside]
#+LATEX_HEADER: \usepackage[utf8]{inputenc}
#+LATEX_HEADER: \usepackage{ae,lmodern}
#+LATEX_HEADER: \usepackage[french]{babel}
#+LATEX_HEADER: \usepackage[T1]{fontenc}
#+LATEX_HEADER: \usepackage{graphicx}
#+LATEX_HEADER: \usepackage[babel=true]{csquotes}
Exported latex preamble:
% Created 2020-07-07 Tue 20:45
% Intended LaTeX compiler: pdflatex
\documentclass[a4paper,11pt,twoside]{article}
\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[utf8]{inputenc}
\usepackage{ae,lmodern}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[babel=true]{csquotes}
\author{}
\date{\today}
\title{}
\hypersetup{
pdfauthor={},
pdftitle={},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 26.2 (Org mode 9.2.5)},
pdflang={French}}
\begin{document}
I used to use the following code to convert #xxx# to \hl{xxx} (using the soul LaTeX package). You might be able to adapt this to convert "xxx" to \enquote{xxx}?
** convert #highlighted# text on export to ~\hl{highlighted}~
#+begin_src emacs-lisp
(defun esf/latex-filter-highlight (text backend info)
"Convert #...# to \hl{...} in LaTeX export."
(when (org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string "#\\([^#]+\\)#" "\\\\hl{\\1}" text)))
(add-to-list 'org-export-filter-plain-text-functions
'esf/latex-filter-highlight)
#+end_src
You do not need csquotes or \enquote{} to get guillemets; there is smart quote support out of the box in Org mode. The following suffices:
#+OPTIONS: ':t
#+LANGUAGE: fr
#+LATEX_HEADER: \usepackage[french]{babel}
* foo
As somebody once said:
"You cannot explain anything to a stone."
You turn on smart quotes, set the #+LANGUAGE to fr to select the french style of smart quotes and then let babel figure it out. The TeX file produced looks like this (only the significant parts are shown):
...
\usepackage[french]{babel}
...
\begin{document}
...
\section{foo}
\label{sec:orgd0ec1fc}
As somebody once said:
\og You cannot explain anything to a stone.\fg{}
\end{document}
If you really want \enquote, you can modify the value of org-export-smart-quotes-alist. I think the best way is to duplcate the current section for fr, modify it for your purposes and add it to the beginning of the alist where it is going to shadow the existing entry:
(setq fr-quotes '("fr"
(primary-opening :utf-8 "« " :html "« " :latex "\\enquote{" :texinfo "#guillemetleft{}#tie{}")
(primary-closing :utf-8 " »" :html " »" :latex "}" :texinfo "#tie{}#guillemetright{}")
(secondary-opening :utf-8 "« " :html "« " :latex "\\\enquote{" :texinfo "#guillemetleft{}#tie{}")
(secondary-closing :utf-8 " »" :html " »" :latex "\\}" :texinfo "#tie{}#guillemetright{}")
(apostrophe :utf-8 "’" :html "’"))
(add-to-list 'org-export-smart-quotes-alist fr-quotes)
As you can see I changed the opening and closing quotes for LaTeX to use \enquote{ to open and } to close. Adding it to the front of the list allows you to get rid of it quickly if you want to go back to the default:
(setq org-export-smart-quotes-alist (cdr org-export-smart-quotes-alist))
gets rid of the first entry (the added "fr" entry) allowing the default "fr" entry to be seen. You should probably do C-h v org-export-smart-quotes-alist and look at its value carefully.
Then the Org mode file becomes:
#+OPTIONS: ':t
#+LANGUAGE: fr
#+LATEX_HEADER: \usepackage[french]{babel}
#+LATEX_HEADER: \usepackage[babel=true]{csquotes}
* foo
As somebody once said:
"You cannot explain anything to a stone."
and the resulting tex file looks like this (again, only the significant parts are shown):
...
\usepackage[french]{babel}
\usepackage[babel=true]{csquotes}
...
\begin{document}
...
\section{foo}
\label{sec:orgb8fcb36}
As somebody once said:
\enquote{You cannot explain anything to a stone.}
\end{document}

Tikz font in beamer export

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:
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}
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?

Org-Mode ignore pagebreak latex cmds in HTML export

I've an org mode file with explicit page breaks using the \pagebreak latex in the file. However if I export it to HTML, I get the literal \pagebreak in the exported file. Is there a way to tell HTML export to ignore such lines?
thanks
SJ
Might try wrapping in Begin and End Latex's like this:
* This is a heading
#+Begin_Latex
\pagebreak
#+End_Latex
* Second heading

Escaping org-mode footnote like text

I've got "[16]" in an org-mode file that is the text you would see in an ipython shell. How do I escape that text so that it does not generate an org-mode footnote? It's fine inside of an example block, but not in the general text. The first [16] is trouble and everything I've tried so far has not produced just straight normal "[16]" in the html output when I export the file.
#+BEGIN_SRC python
def setfrequency():
print 'Setting frequency'
# Write code here to set the frequency
setfrequency()
#+END_SRC
# This next line is the footnote problem
Run it again and you should see this, but the command number [16]
will be different for you:
#+BEGIN_EXAMPLE
In [16]: run sonar # This does not export as a footnote.
Setting frequency
#+END_EXAMPLE
Thanks!
You can escape syntax using =[1]= (code) or ~[1]~ (verbatim) blocks. See the Org-Manual section on Emphasis and Monospace.
* This will export the footnote style brackets verbatim
[1] by itself will fail
=[1]= and ~[1]~ will export as is.
The relevant portion of HTML export for this is
<p class="footnote"><sup><a class="footnum" name="fn.1" href="#fnr.1">1</a>
</sup> by itself will fail
<code>[1]</code> and <code>[1]</code> will export as is.
</p>
<p class="footnote"><sup><a class="footnum" name="fn.1" href="#fnr.1">1</a>
</sup> DEFINITION NOT FOUND: 1
I tried this way.
Run it again and you should see this, but the command number
#+latex: [16]
will be different for you: