I got sick of adding #+OPTIONS: ^:{} to the top of all of my .org files, so I thought I'd try to get that behavior once and for all by editing my .emacs file. Based on available documentation, it seems like
(setq org-export-with-sub-superscripts "{}")
would achieve the same behavior as #+OPTIONS: ^:{}, although when I do the (setq ... thing on its own, both A_B and A_{B} are rendered as A<sub>B</sub> in the HTML output. To ensure org-export-with-sub-superscripts is the right variable, I tried
(setq org-export-with-sub-superscripts nil)
which caused A_B to be rendered as A_B and A_{B} to be rendered as A_{B}—exactly what you'd expect. I've also tried '"{}", and (setq org-use-sub-superscripts "{}") (with and without quoting "{}"), neither of which worked.
I had this problem in Org mode 7.9.3, and it's followed me to 8.2.10. Any ideas what I'm doing incorrectly?
You must write instead:
(setq org-use-sub-superscripts '{})
Another approach is to define a template based on your #+OPTIONS
example:
here I have a template file to export to HTML which contains
---- level-0-html.org--------
#+DRAWERS: HIDDEN PROPERTIES STATE CABECALHO COMENTARIOS
:CABECALHO:
# # desabilita o superscrito/subscrito | não exporta programação
#+OPTIONS: ^:nil p:nil
#+OPTIONS: tags:nil
#+STARTUP: showeverything
#+STYLE: <link rel="stylesheet" type="text/css" href="../../css/leslie.css" />
#+LANGUAGE: pt_BR
#+OPTIONS: H:2 num:t toc:f \n:nil #:t ::t |:t ^:t -:t f:t *:t <:t
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+TAGS: export(e) noexport(n)
#+LINK_UP:
#+LINK_HOME:
:END:
#+TITLE:
#+AUTHOR: Leslie H. Watter
#+EMAIL:
#+DATE:
------------------------------------------------
and in my org-file that I'll export I have:
----- presentation.org ------
#+SETUPFILE: ~/org/templates/level-0-html.org
#+TITLE: Gerência de Redes
#+AUTHOR: Leslie H. Watter
#+EMAIL: hooorayyyy # my domain .com
* Gerência de Redes
(and here goes the entire file)
------
This way I get a consistent way of exporting.
References: http://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html#sec-6
Related
I am trying to add email address in my org mode document which has to be exported to PDF.
This is my header tags.
#+TITLE: Main Title
#+SUBTITLE: Sub Title
#+AUTHOR: Author Name
#+EMAIL: author#email.com
All the first three tags are getting exported except email header.
I tried the option
#+OPTIONS: toc:nil email:t
but still it is not working.
Could anyone throw light on where I am doing the mistake?
Exporting to PDF is via LaTeX and there is no standard entry for email in the LaTeX export. In other words, the standard LaTeX article class, used by the exporter by default, does not know what to do with an email address.
However, org creates a macro, email, which you can use to place the email address in any place you wish within the document by using {{{email}}}, including, for instance, after the author name on the #+AUTHOR line.
I got the solution from emacs-orgmode mailing list.
Accessing #+EMAIL in latex export.
We need to create a filter function to replace #EMAIL# in the contents (I don't what's the content we are getting) and add this function to org-export-filter-final-output-functions. The code snippet is:
(defun nd-email-filter (contents backend info)
(let ((email (plist-get info :email)))
(replace-regexp-in-string "#EMAIL#" email contents t)))
(add-to-list 'org-export-filter-final-output-functions (function nd-email-filter))
(setq amsart-class
'("amsart"
"\\documentclass{amsart}
[DEFAULT-PACKAGES]
[PACKAGES]
[EXTRA]
{#EMAIL#}"
("\\section{%s}" . "\\section{%s}")
("\\subsection{%s}" . "\\subsection{%s}")
("\\subsubsection{%s}" . "\\subsubsection{%s}")))
(add-to-list 'org-latex-classes amsart-class)
Then, within our latex class definition as shown above, we can use #EMAIL# where ever, we want the email to be displayed.
I used it as follows:
(add-to-list 'org-latex-classes
'("ethz"
"\\documentclass[a4paper,11pt,article]{memoir}
\\usepackage[utf8]{inputenc}
...
\\usepackage{parskip}
\\makeatletter
\\renewcommand{\\maketitle}{%
\\begingroup\\parindent0pt
\\Small{Aum Tat Sat!}\\par\\bigskip
\\Huge{\\bfseries\\#title}\\par
\\LARGE{\\#subtitle}\\par\\bigskip
\\small{\\#author}\\par\\smallskip
\\small{#EMAIL#}\\par\\smallskip
\\normalsize\\#date\\par\\bigskip
\\endgroup\\#afterindentfalse\\#afterheading}
\\makeatother
[PACKAGES]
[EXTRA]
\\linespread{1.1}
...
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
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}
I used to use markdown all the time. Now I use emacs org-mode for everything ("this koolaid tastes good"). One piece that kept driving me nuts was the ability to use backticks for inline code in emacs.
Everything I read wanted me to use easy templates for source code like this:
#+BEGIN_SRC
Just add: " < " + one of the letters below
s #+BEGIN_SRC ... #+END_SRC
e #+BEGIN_EXAMPLE ... #+END_EXAMPLE
q #+BEGIN_QUOTE ... #+END_QUOTE
v #+BEGIN_VERSE ... #+END_VERSE
c #+BEGIN_CENTER ... #+END_CENTER
l #+BEGIN_LaTeX ... #+END_LaTeX
L #+LaTeX:
h #+BEGIN_HTML ... #+END_HTML
H #+HTML:
a #+BEGIN_ASCII ... #+END_ASCII
A #+ASCII:
i #+INDEX: line
I #+INCLUDE: line
#+END_SRC
Then I stumbled onto the post by Mr. Abrams: Exporting inline code to html in org-mode. I just need to use =code= instead of 'code' for emacs inline quotes? OK. Why isn't this noted somewhere simple in the months worth of docs I've been perusing!? (It probably is!)
Now of course, I want to know how to customize the color, font, and size of these inline code snippets in emacs. The default size is too small and there is no subtle background color like with markdown.
Thank you
I believe Org Mode exports your current color theme. To verify that, you can change the colour scheme of your emacs and re-export your buffer to see if things change.
As for myself, I set org-html-htmlize-output-type to css and org-html-head to the following:
<link rel="stylesheet" type="text/css" href="path/to/my.css" />
This way, I can tune the css as I want regardless the colour theme of my emacs.
Below please see the help of org-html-htmlize-output-type:
org-html-htmlize-output-type is a variable defined in ‘ox-html.el’. Its value is ‘css’ Original value was inline-css
Documentation: Output type to be used by htmlize when formatting code snippets. Choices are ‘css’ to export the CSS selectors only,‘inline-css’ to export the CSS attribute values inline in the HTML or ‘nil’ to export plain text. We use as default ‘inline-css’, in order to make the resulting HTML self-containing.
…
To get a start for your css file, start Emacs session and make sure that all the faces you are interested in are defined, for example by loading files in all modes you want. Then, use the command ‘M-x org-html-htmlize-generate-css’ to extract class definitions.
You can customize this variable.
EDIT
Please put the following to your init.el, restart emacs and retry to see if it works:
(setq org-html-htmlize-output-type 'css)
(setq-default org-html-head "<link rel=\"stylesheet\" .../>")
I just need to use =code= instead of 'code' for emacs inline quotes?
I think this is because you didn't go through the manual carefully. Monospace is described in 11.2 Emphasis and Monospace
You can make words ‘bold’, ‘/italic/’, ‘underlined’, ‘=verbatim=’ and ‘~code~
If you want to represent a code block, you can use #+BEGIN_SRC and #+END_SRC pair.
#+BEGIN_SRC emacs-lisp
(defun org-xor (a b)
"Exclusive or."
(if a (not b) b))
#+END_SRC
As you have mentioned in your question description, you can type <s and TAB for auto completion.
I want to know how to customize the color, font, and size of these inline code snippets in emacs.
There are two levels to set font in org.
Change the font on a document-wide level
Add below #+HTML_HEAD_EXTRA: to the begin of your org file.
#+HTML_HEAD_EXTRA: <style>*{font-family:Arial,'Times New Roman','Microsoft YaHei',SimHei; font-size: 20px; font-style: italic; !important}</style>
#Lungang Fang gives you another way to place CSS.
Change the font size locally
#+BEGIN_EXPORT html
<p style="font-family:Monospace; font-size: 30px; font-style: italic;">
This is a customized line.
</p>
#+END_EXPORT
To customize the style of a block mentioned in your quetion description, you can see my other answer.
I use the great org-mode to easily push modifications of README.md to GitHub projects. Markdown export works great, except for the #+TITLE option not being exported to Markdown - which works flawlessly for HTML export.
I want to keep the file name README.org for convenient converting to Markdown, else I could have chosen the title as file name, which displays the title correctly on GitHub.
Any suggestions on how to achieve this?
Based on your question and subsequent comments, you seem to want to achieve three things:
Define a custom title that gets exported as a top-level headline.
Insert the TOC after the title.
The TOC should not include the title.
Custom location for TOC
Inserting the TOC at a custom location is easy, so let's start with that: Add
#+OPTIONS: toc:nil
to the export options at the top of README.org. By itself, this tells org-mode not to include the default TOC when exporting. You can then place the TOC where you want it to go by inserting
#+TOC: headlines
at the desired location. (This method is not specific to Markdown export.)
Custom title that doesn't show up in TOC
Defining a custom title that is not included in the TOC is a bit trickier, but the basic idea is to exclude the title from the TOC by formatting it as a Markdown headline instead of an org headline. As a first step, change README.org to look like this:
#+OPTIONS: toc:nil
# Emacs als Python-Power-Editor für den RasPi
#+TOC: headlines
* Wieso nur ausgerechnet Emacs???
...
Out of the box this won't yield the desired results because org will interpret the title as a comment and by default the Markdown exporter is configured to ignore comments. However, in order to change the default behavior you can
define a custom transcoder for comments in your .emacs:
(defun org-md-comment (comment contents info)
"Transcode COMMENT object into Markdown format.
CONTENTS is nil. INFO is a plist holding contextual information."
(format "# %s" (org-element-property :value comment)))
redefine the Markdown export backend to make use of this transcoder:
(org-export-define-derived-backend 'md 'html
;; ...
:translate-alist '((bold . org-md-bold)
(code . org-md-verbatim)
(comment . org-md-comment) ;; <--- Use custom transcoder
(comment-block . (lambda (&rest args) ""))
;; ...
))
The original definition of the backend can be found in the file ox-md.el; this file is located in the directory of your org-mode installation. You'll need to copy the full definition to your .emacs file and change the line
(comment . (lambda (&rest args) ""))
as shown above.
Results
With these customizations the resulting README.md file looks like this:
# Emacs als Python-Power-Editor für den RasPi
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li>1. Wieso nur ausgerechnet Emacs???</li>
<li>2. Die Maus ist tot, es leben die shortcuts!</li>
<li>3. Auf den Emacs, fertig, los!</li>
</ul>
</div>
</div>
# Wieso nur ausgerechnet Emacs???
...
See http://article.gmane.org/gmane.emacs.orgmode/82634.
The problem is supposed to be fixed. Only waiting for an update of the converter on GitHub site...
This is useful to get what the answer expects but I think it is not the right path to resolve this question. Let me explain it
I think the issue is about exporting options from org-mode to md but I also want to keep my docs in org-mode and this hacks org-mode export option adding another line for title exporting to md headline 1 but not manages the whole thing.
What I expect and I guess this is the important issue is to export orgmode to md properly, I mean:
the title from orgmode to md heading one (#) -as orgmode to html does.
the heading one from orgmode (*) to md heading two (##)
If this issue is not about it I should open a new one :)
Best!
When I create a new org-mode file, I create a header similar to this:
#+TITLE: Some title
#+AUTHOR: Me
#+CATEGORY: things
#+STARTUP: align fold nodlcheck oddeven lognotestate
#+OPTIONS: H:4 num:nil toc:t \n:nil #:t ::t |:t ^:{} -:t f:t *:t
#+OPTIONS: skip:nil d:(HIDE) tags:not-in-toc
#+LANGUAGE: en
#+PROPERTY: header-args :results code :exports both :noweb yes
However, when I specify the #+PROPERTY setting, it doesn't take effect until I reopen the file.
How can I force org-mode to re-read header configuration without closing the buffer and reopening it?
You could do a M-x revert-buffer. This is, in short, a „re-open file from disk” macro.