Exporting accented characters to latex from org-mode

| categories: uncategorized | tags:

I noticed recently in writing a technical paper in org-mode that I had some trouble exporting some accented characters to LaTeX.

Here are 5 words that render correctly in LaTeX

1. Jos\'{e}
2. peque\~{n}o
3. Gro\ss
4. Gr\"{u}neisen
5. N\o{}rskov

Here we wrap these words in a LaTeX block so it exports verbatim to see how they look in a PDF.

Note to see this in LaTeX, you must view the exporting-accented-characters.pdf. Now, we use the same characters in org-mode.

  1. Jos\'{e}
  2. peque\~{n}o
  3. Gro\ss
  4. Gr\"{u}neisen
  5. N\o{}rskov

The exported LaTeX code looks like:

\begin{enumerate}
\item Jos$\backslash$'\{e\}
\item peque$\backslash$\textasciitilde{}\{n\}o
\item Gro\ss
\item Gr$\backslash$"\{u\}neisen
\item N\o{}rskov
\end{enumerate}

The exporter does not handle all of them correctly. Org-mode is its own system, and it is not, and won't be a total replacement for LaTeX. Nevertheless, these are pretty common characters for me, and We need a solution! A clunky way we found to solve this is to add a LATEXHEADER line that defines a new LaTeX command like this:

#+LATEX_HEADER: \newcommand{\gruneisen}{Gr\"{u}neisen}

Then you can use the new command in org-mode. So this text:

We use \gruneisen in a sentence.

Renders like this:

We use \gruneisen in a sentence.

That is not too ideal, since some journals do not like you to define new commands. It turns out that org-mode has its own commands to solve this problem! There is a list of these commands stored in a variable called org-entities.

Here we print these entities for "the record". I add an extra star to the data in org-entities so they will all be nested in this post.

(mapcar (lambda(x)
  "print element x. If it is a heading, add an extra star"
  (interactive)
  (if (and (stringp x) (string= (substring x 0 1) "*"))
      (princ (format "*%s\n" x))
    (princ (format "%s\n" x)))) org-entities)

1 Letters

1.1 Latin

(Agrave \`{A} nil À A À À) (agrave \`{a} nil à a à à) (Aacute \'{A} nil Á A Á Á) (aacute \'{a} nil á a á á) (Acirc \A nil  A  Â) (acirc \a nil â a â â) (Atilde \~{A} nil à A à Ã) (atilde \~{a} nil ã a ã ã) (Auml \"{A} nil Ä Ae Ä Ä) (auml \"{a} nil ä ae ä ä) (Aring Å nil Å A Å Å) (AA Å nil Å A Å Å) (aring \aa{} nil å a å å) (AElig \AE{} nil Æ AE Æ Æ) (aelig \ae{} nil æ ae æ æ) (Ccedil \c{C} nil Ç C Ç Ç) (ccedil \c{c} nil ç c ç ç) (Egrave \`{E} nil È E È È) (egrave \`{e} nil è e è è) (Eacute \'{E} nil É E É É) (eacute \'{e} nil é e é é) (Ecirc \E nil Ê E Ê Ê) (ecirc \e nil ê e ê ê) (Euml \"{E} nil Ë E Ë Ë) (euml \"{e} nil ë e ë ë) (Igrave \`{I} nil Ì I Ì Ì) (igrave \`{i} nil ì i ì ì) (Iacute \'{I} nil Í I Í Í) (iacute \'{i} nil í i í í) (Icirc \I nil Î I Î Î) (icirc \i nil î i î î) (Iuml \"{I} nil Ï I Ï Ï) (iuml \"{i} nil ï i ï ï) (Ntilde \~{N} nil Ñ N Ñ Ñ) (ntilde \~{n} nil ñ n ñ ñ) (Ograve \`{O} nil Ò O Ò Ò) (ograve \`{o} nil ò o ò ò) (Oacute \'{O} nil Ó O Ó Ó) (oacute \'{o} nil ó o ó ó) (Ocirc \O nil Ô O Ô Ô) (ocirc \o nil ô o ô ô) (Otilde \~{O} nil Õ O Õ Õ) (otilde \~{o} nil õ o õ õ) (Ouml \"{O} nil Ö Oe Ö Ö) (ouml \"{o} nil ö oe ö ö) (Oslash \O nil Ø O Ø Ø) (oslash \o{} nil ø o ø ø) (OElig \OE{} nil Œ OE OE Œ) (oelig \oe{} nil œ oe oe œ) (Scaron \v{S} nil Š S S Š) (scaron \v{s} nil š s s š) (szlig \ss{} nil ß ss ß ß) (Ugrave \`{U} nil Ù U Ù Ù) (ugrave \`{u} nil ù u ù ù) (Uacute \'{U} nil Ú U Ú Ú) (uacute \'{u} nil ú u ú ú) (Ucirc \U nil Û U Û Û) (ucirc \u nil û u û û) (Uuml \"{U} nil Ü Ue Ü Ü) (uuml \"{u} nil ü ue ü ü) (Yacute \'{Y} nil Ý Y Ý Ý) (yacute \'{y} nil ý y ý ý) (Yuml \"{Y} nil Ÿ Y Y Ÿ) (yuml \"{y} nil ÿ y ÿ ÿ)

1.2 Latin (special face)

(fnof \textit{f} nil ƒ f f ƒ) (real \Re t ℜ R R ℜ) (image \Im t ℑ I I ℑ) (weierp \wp t ℘ P P ℘)

1.3 Greek

(Alpha A nil Α Alpha Alpha Α) (alpha α t α alpha alpha α) (Beta B nil Β Beta Beta Β) (beta β t β beta beta β) (Gamma Γ t Γ Gamma Gamma Γ) (gamma γ t γ gamma gamma γ) (Delta Δ t Δ Delta Gamma Δ) (delta δ t δ delta delta δ) (Epsilon E nil Ε Epsilon Epsilon Ε) (epsilon ε t ε epsilon epsilon ε) (varepsilon ε t ε varepsilon varepsilon ε) (Zeta Z nil Ζ Zeta Zeta Ζ) (zeta ζ t ζ zeta zeta ζ) (Eta H nil Η Eta Eta Η) (eta η t η eta eta η) (Theta Θ t Θ Theta Theta Θ) (theta θ t θ theta theta θ) (thetasym ϑ t ϑ theta theta ϑ) (vartheta ϑ t ϑ theta theta ϑ) (Iota I nil Ι Iota Iota Ι) (iota ι t ι iota iota ι) (Kappa K nil Κ Kappa Kappa Κ) (kappa κ t κ kappa kappa κ) (Lambda Λ t Λ Lambda Lambda Λ) (lambda λ t λ lambda lambda λ) (Mu M nil Μ Mu Mu Μ) (mu μ t μ mu mu μ) (nu ν t ν nu nu ν) (Nu N nil Ν Nu Nu Ν) (Xi Ξ t Ξ Xi Xi Ξ) (xi ξ t ξ xi xi ξ) (Omicron O nil Ο Omicron Omicron Ο) (omicron \textit{o} nil ο omicron omicron ο) (Pi Π t Π Pi Pi Π) (pi π t π pi pi π) (Rho P nil Ρ Rho Rho Ρ) (rho ρ t ρ rho rho ρ) (Sigma Σ t Σ Sigma Sigma Σ) (sigma σ t σ sigma sigma σ) (sigmaf ς t ς sigmaf sigmaf ς) (varsigma ς t ς varsigma varsigma ς) (Tau T nil Τ Tau Tau Τ) (Upsilon Υ t Υ Upsilon Upsilon Υ) (upsih Υ t ϒ upsilon upsilon ϒ) (upsilon υ t υ upsilon upsilon υ) (Phi Φ t Φ Phi Phi Φ) (phi φ t φ phi phi φ) (Chi X nil Χ Chi Chi Χ) (chi χ t χ chi chi χ) (acutex ´ x t ´x 'x 'x 𝑥́) (Psi Ψ t Ψ Psi Psi Ψ) (psi ψ t ψ psi psi ψ) (tau τ t τ tau tau τ) (Omega Ω t Ω Omega Omega Ω) (omega ω t ω omega omega ω) (piv \varpi t ϖ omega-pi omega-pi ϖ) (partial ∂ t ∂ [partial differential] [partial differential] ∂)

1.4 Hebrew

(alefsym \aleph t ℵ aleph aleph ℵ)

1.5 Dead languages

(ETH \DH{} nil Ð D Ð Ð) (eth \dh{} nil ð dh ð ð) (THORN \TH{} nil Þ TH Þ Þ) (thorn \th{} nil þ th þ þ)

2 Punctuation

2.1 Dots and Marks

(dots … nil … … … …) (hellip … nil … … … …) (middot \textperiodcentered{} nil · . · ·) (iexcl !` nil ¡ ! ¡ ¡) (iquest ?` nil ¿ ? ¿ ¿)

2.2 Dash-like

(shy ­ nil ­ ) (ndash – nil – - - –) (mdash — nil — – – —)

2.3 Quotations

(quot \textquotedbl{} nil &quot; " " ") (acute \textasciiacute{} nil &acute; ' ´ ´) (ldquo \textquotedblleft{} nil &ldquo; " " “) (rdquo \textquotedblright{} nil &rdquo; " " ”) (bdquo \quotedblbase{} nil &bdquo; " " „) (lsquo \textquoteleft{} nil &lsquo; ` ` ‘) (rsquo \textquoteright{} nil &rsquo; ' ' ’) (sbquo \quotesinglbase{} nil &sbquo; , , ‚) (laquo \guillemotleft{} nil &laquo; << « «) (raquo \guillemotright{} nil &raquo; >> » ») (lsaquo \guilsinglleft{} nil &lsaquo; < < ‹) (rsaquo \guilsinglright{} nil &rsaquo; > > ›)

3 Other

3.1 Misc. (often used)

(circ \nil nil &circ; ^ ^ ˆ) (vert | t &#124; | | |) (brvbar \textbrokenbar{} nil &brvbar; | ¦ ¦) (sect \S nil &sect; paragraph § §) (amp \& nil &amp; & & &) (lt \textless{} nil &lt; < < <) (gt \textgreater{} nil &gt; > > >) (tilde \~{} nil &tilde; ~ ~ ~) (slash / nil / / / /) (plus + nil + + + +) (under \_ nil _ _ _ _) (equal = nil = = = =) (asciicirc \textasciicircum{} nil ^ ^ ^ ^) (dagger \textdagger{} nil &dagger; [dagger] [dagger] †) (Dagger \textdaggerdbl{} nil &Dagger; [doubledagger] [doubledagger] ‡)

3.2 Whitespace

(nbsp ~ nil &nbsp; ) (ensp \hspace*{.5em} nil &ensp;  ) (emsp \hspace*{1em} nil &emsp;  ) (thinsp \hspace*{.2em} nil &thinsp;  )

3.3 Currency

(curren \textcurrency{} nil &curren; curr. ¤ ¤) (cent \textcent{} nil &cent; cent ¢ ¢) (pound \pounds{} nil &pound; pound £ £) (yen \textyen{} nil &yen; yen ¥ ¥) (euro \texteuro{} nil &euro; EUR EUR €) (EUR € nil &euro; EUR EUR €) (EURdig € nil &euro; EUR EUR €) (EURhv € nil &euro; EUR EUR €) (EURcr € nil &euro; EUR EUR €) (EURtm € nil &euro; EUR EUR €)

3.4 Property Marks

(copy \textcopyright{} nil &copy; (c) © ©) (reg \textregistered{} nil &reg; (r) ® ®) (trade \texttrademark{} nil &trade; TM TM ™)

3.5 Science et al.

(minus − t &minus; - - −) (pm \textpm{} nil &plusmn; +- ± ±) (plusmn \textpm{} nil &plusmn; +- ± ±) (times \texttimes{} nil &times; * × ×) (frasl / nil &frasl; / / ⁄) (div \textdiv{} nil &divide; / ÷ ÷) (frac12 \textonehalf{} nil &frac12; 1/2 ½ ½) (frac14 \textonequarter{} nil &frac14; 1/4 ¼ ¼) (frac34 \textthreequarters{} nil &frac34; 3/4 ¾ ¾) (permil \textperthousand{} nil &permil; per thousand per thousand ‰) (sup1 \textonesuperior{} nil &sup1; ^1 ¹ ¹) (sup2 \texttwosuperior{} nil &sup2; ^2 ² ²) (sup3 \textthreesuperior{} nil &sup3; ^3 ³ ³) (radic \sqrt{\,} t &radic; [square root] [square root] √) (sum ∑ t &sum; [sum] [sum] ∑) (prod ∏ t &prod; [product] [n-ary product] ∏) (micro \textmu{} nil &micro; micro µ µ) (macr \textasciimacron{} nil &macr; [macron] ¯ ¯) (deg \textdegree{} nil &deg; degree ° °) (prime ′ t &prime; ' ' ′) (Prime ′′ t &Prime; '' '' ″) (infin \propto t &infin; [infinity] [infinity] ∞) (infty ∞ t &infin; [infinity] [infinity] ∞) (prop \propto t &prop; [proportional to] [proportional to] ∝) (proptp \propto t &prop; [proportional to] [proportional to] ∝) (not \textlnot{} nil &not; [angled dash] ¬ ¬) (neg ¬ t &not; [angled dash] ¬ ¬) (land ∧ t &and; [logical and] [logical and] ∧) (wedge ∧ t &and; [logical and] [logical and] ∧) (lor ∨ t &or; [logical or] [logical or] ∨) (vee ∨ t &or; [logical or] [logical or] ∨) (cap ∩ t &cap; [intersection] [intersection] ∩) (cup ∪ t &cup; [union] [union] ∪) (int ∫ t &int; [integral] [integral] ∫) (there4 \therefore t &there4; [therefore] [therefore] ∴) (sim ∼ t &sim; ~ ~ ∼) (cong ≅ t &cong; [approx. equal to] [approx. equal to] ≅) (simeq ≅ t &cong; [approx. equal to] [approx. equal to] ≅) (asymp ≈ t &asymp; [almost equal to] [almost equal to] ≈) (approx ≈ t &asymp; [almost equal to] [almost equal to] ≈) (ne ≠ t &ne; [not equal to] [not equal to] ≠) (neq ≠ t &ne; [not equal to] [not equal to] ≠) (equiv ≡ t &equiv; [identical to] [identical to] ≡) (le ≤ t &le; <= <= ≤) (ge ≥ t &ge; >= >= ≥) (sub ⊂ t &sub; [subset of] [subset of] ⊂) (subset ⊂ t &sub; [subset of] [subset of] ⊂) (sup ⊃ t &sup; [superset of] [superset of] ⊃) (supset ⊃ t &sup; [superset of] [superset of] ⊃) (nsub ¬⊂ t &nsub; [not a subset of] [not a subset of ⊄) (sube \subseteq t &sube; [subset of or equal to] [subset of or equal to] ⊆) (nsup ¬⊃ t &nsup; [not a superset of] [not a superset of] ⊅) (supe \supseteq t &supe; [superset of or equal to] [superset of or equal to] ⊇) (forall ∀ t &forall; [for all] [for all] ∀) (exist ∃ t &exist; [there exists] [there exists] ∃) (exists ∃ t &exist; [there exists] [there exists] ∃) (empty ∅ t &empty; [empty set] [empty set] ∅) (emptyset ∅ t &empty; [empty set] [empty set] ∅) (isin ∈ t &isin; [element of] [element of] ∈) (in ∈ t &isin; [element of] [element of] ∈) (notin ∉ t &notin; [not an element of] [not an element of] ∉) (ni ∋ t &ni; [contains as member] [contains as member] ∋) (nabla ∇ t &nabla; [nabla] [nabla] ∇) (ang ∠ t &ang; [angle] [angle] ∠) (angle ∠ t &ang; [angle] [angle] ∠) (perp ⊥ t &perp; [up tack] [up tack] ⊥) (sdot ⋅ t &sdot; [dot] [dot] ⋅) (cdot ⋅ t &sdot; [dot] [dot] ⋅) (lceil ⌈ t &lceil; [left ceiling] [left ceiling] ⌈) (rceil ⌉ t &rceil; [right ceiling] [right ceiling] ⌉) (lfloor ⌊ t &lfloor; [left floor] [left floor] ⌊) (rfloor ⌋ t &rfloor; [right floor] [right floor] ⌋) (lang \langle t &lang; < < ⟨) (rang \rangle t &rang; > > ⟩) (hbar ℏ t &#8463; hbar hbar ℏ)

3.6 Arrows

(larr ← t &larr; <- <- ←) (leftarrow ← t &larr; <- <- ←) (gets ← t &larr; <- <- ←) (lArr ⇐ t &lArr; <= <= ⇐) (Leftarrow ⇐ t &lArr; <= <= ⇐) (uarr ↑ t &uarr; [uparrow] [uparrow] ↑) (uparrow ↑ t &uarr; [uparrow] [uparrow] ↑) (uArr ⇑ t &uArr; [dbluparrow] [dbluparrow] ⇑) (Uparrow ⇑ t &uArr; [dbluparrow] [dbluparrow] ⇑) (rarr → t &rarr; -> -> →) (to → t &rarr; -> -> →) (rightarrow → t &rarr; -> -> →) (rArr ⇒ t &rArr; => => ⇒) (Rightarrow ⇒ t &rArr; => => ⇒) (darr ↓ t &darr; [downarrow] [downarrow] ↓) (downarrow ↓ t &darr; [downarrow] [downarrow] ↓) (dArr ⇓ t &dArr; [dbldownarrow] [dbldownarrow] ⇓) (Downarrow ⇓ t &dArr; [dbldownarrow] [dbldownarrow] ⇓) (harr ↔ t &harr; <-> <-> ↔) (leftrightarrow ↔ t &harr; <-> <-> ↔) (hArr ⇔ t &hArr; <=> <=> ⇔) (Leftrightarrow ⇔ t &hArr; <=> <=> ⇔) (crarr ↵ t &crarr; <-' <-' ↵) (hookleftarrow ↵ t &crarr; <-' <-' ↵)

3.7 Function names

(arccos arccos t arccos arccos arccos arccos) (arcsin arcsin t arcsin arcsin arcsin arcsin) (arctan arctan t arctan arctan arctan arctan) (arg arg t arg arg arg arg) (cos cos t cos cos cos cos) (cosh cosh t cosh cosh cosh cosh) (cot cot t cot cot cot cot) (coth coth t coth coth coth coth) (csc csc t csc csc csc csc) (deg ° t &deg; deg deg deg) (det det t det det det det) (dim dim t dim dim dim dim) (exp exp t exp exp exp exp) (gcd gcd t gcd gcd gcd gcd) (hom hom t hom hom hom hom) (inf inf t inf inf inf inf) (ker ker t ker ker ker ker) (lg lg t lg lg lg lg) (lim lim t lim lim lim lim) (liminf liminf t liminf liminf liminf liminf) (limsup limsup t limsup limsup limsup limsup) (ln ln t ln ln ln ln) (log log t log log log log) (max max t max max max max) (min min t min min min min) (Pr Pr t Pr Pr Pr Pr) (sec sec t sec sec sec sec) (sin sin t sin sin sin sin) (sinh sinh t sinh sinh sinh sinh) (sup ⊃ t &sup; sup sup sup) (tan tan t tan tan tan tan) (tanh tanh t tanh tanh tanh tanh)

3.8 Signs & Symbols

(bull \textbullet{} nil &bull; * * •) (bullet \textbullet{} nil &bull; * * •) (star * t * * * ⋆) (lowast ∗ t &lowast; * * ∗) (ast ∗ t &lowast; * * *) (odot o t o [circled dot] [circled dot] ʘ) (oplus ⊕ t &oplus; [circled plus] [circled plus] ⊕) (otimes ⊗ t &otimes; [circled times] [circled times] ⊗) (checkmark ✓ t &#10003; [checkmark] [checkmark] ✓)

3.9 Miscellaneous (seldom used)

(para \P{} nil &para; [pilcrow] ¶ ¶) (ordf \textordfeminine{} nil &ordf; a ª ª) (ordm \textordmasculine{} nil &ordm; o º º) (cedil \c{} nil &cedil; [cedilla] ¸ ¸) (oline \overline{~} t &oline; [overline] ¯ ‾) (uml \textasciidieresis{} nil &uml; [diaeresis] ¨ ¨) (zwnj \/{} nil &zwnj; ‌) (zwj nil &zwj; ‍) (lrm nil &lrm; ‎) (rlm nil &rlm; ‏)

3.10 Smilies

(smile ☺ t &#9786; :-) :-) ⌣) (smiley ☺ nil &#9786; :-) :-) ☺) (blacksmile \blacksmiley{} nil &#9787; :-) :-) ☻) (sad \frownie{} nil &#9785; :-( :-( ☹)

3.11 Suits

(clubs ♣ t &clubs; [clubs] [clubs] ♣) (clubsuit ♣ t &clubs; [clubs] [clubs] ♣) (spades ♠ t &spades; [spades] [spades] ♠) (spadesuit ♠ t &spades; [spades] [spades] ♠) (hearts ♥ t &hearts; [hearts] [hearts] ♥) (heartsuit ♥ t &heartsuit; [hearts] [hearts] ♥) (diams ♦ t &diams; [diamonds] [diamonds] ♦) (diamondsuit ♦ t &diams; [diamonds] [diamonds] ♦) (Diamond \diamond t &diamond; [diamond] [diamond] ⋄) (loz \diamond t &loz; [lozenge] [lozenge] ◊)

4 Summary.

Wow, there are a lot of commands ☺. We just need to use them. For example, I can write Grüneisen, and it finally renders the way it should!

Copyright (C) 2013 by John Kitchin. See the License for information about copying.

org-mode source

Discuss on Twitter