how to get smart quotes on org-mode export? - emacs

How do I get Emacs org-mode to create proper typographic marks when I export to HTML, including converting straight quotes to smart quotes ("curly quotes") and converting hyphens --- to m-dashes —?

#+LANGUAGE: de
#+OPTIONS: ':t
also does the right thing now

This is now built into org-mode 8.x. To activate it, add the following to your Emacs configuration file:
(setq org-export-with-smart-quotes t)
It works for single quotes, double quotes, and apostrophes.
Source: #Ista

This is only available in very recent versions of org-mode. If you are not already running the latest git version see http://orgmode.org/worg/org-faq.html#keeping-current-with-Org-mode-development for instructions on upgrading. Then (setq org-export-with-smart-quotes t) will do what you want with quotes, and m-dashes will also be exported correctly.

A way to insure that smart quotes are entered in your org file is to insert the code at the following url into your init.el file. Then type M-x smart-quotes-mode and your all set.
https://github.com/gareth-rees/smart-quotes/blob/master/smart-quotes.el
MNH

Related

Disable certain org mode markup

I want to be able to disable strikethrough happening when I type + in an org-mode document. Specifically it is for entries in a table. Is there an easy way of doing this for a specific org-mode document since I only want to disable it for one document in particular. If not a way to toggle this would be nice.
I know I can have a literal + symbol with \plus but I would like to be able to see it in the document rather than reading the \plus.
To disable strikethrough in a specific file, add the following to your file:
-*- org-emphasis-alist: (("*" bold) ("/" italic) ("_" underline) ("=" org-verbatim verbatim) ("~" org-code verbatim) ("+" (:strike-through nil))); -*-
The down-side is that it will complain that the file may contain values that are not safe (see here). You can also use the longer version at the bottom of your file, as mentioned here.
To do it for all your org files is a simpler, and will not ask questions:
(setq org-emphasis-alist (quote (("*" bold "<b>" "</b>")
("/" italic "<i>" "</i>")
("_" underline "<span style=\"text-decoration:underline;\">" "</span>")
("=" org-code "<code>" "</code>" verbatim)
("~" org-verbatim "<code>" "</code>" verbatim))))
Sources: Bernt Hansen's org-mode notes(a must-read) and the org manual
I was able to do it by using local variables in the file
# Local Variables:
# org-emphasis-alist: (everything but strike through)
# End:
You can set org-emphasis-alist for just one file:
-*- org-emphasis-alist: nil -*-
+not struckout+
Of course, this removes all emphasis (bold, italic, etc.). I cannot figure out how to remove just strikeout in just one file (specifically, I can't figure out how to delete an element of the alist locally).
You might be able to achieve this by defining an overlay (+) for the literal plus (\plus). There is a library called "Auto Overlays" that
allows you to define overlays that are created (and updated and destroyed) automatically when text in a buffer matches a regular expression
(quoted from the home page of the author).
You can download a standalone version of the library from here. If you are on Emacs 24 and have the Marmalade Repo enabled, you can install the predictive package via
M-x package-install RET predictive RET
which apparently includes "Auto Overlays".
The documentation for this library is here.

how to avoid emacs' replacing quotation marks in French

When you use babel with French (set by, \usepackage[francais]{babel} emacs replaces automatically quotations marks (") by \og and \fg (you need only to restart emacs after adding babel).
It could be quite cool. But I'm using csquotes package which allows to have the good quotation marks by simply writing ".
\usepackage[babel]{csquotes}
\MakeOuterQuote{"}
So this amazing feature of emacs (the automatic replacement of " by \og or \fg) is useless for me and even painful.
How do I remove it?
It seems it is the font-latex-quotes variable which manage this. But options are only French (<< >>) or German (>> <<). I would like to redefine this variable to consider "test" as quote with test in color.
Assuming you are using auctex. you need to customize the value of variable TeX-quote-language to 'override.
This special value makes that language-related styles inhibit to modify its value, so quoting magic is deactivated.
I fixed this issue by modifying the variables LaTeX-csquotes-open-quote and LaTeX-csquotes-close-quote.
I define the first variable as \enquote{ and the second as }.

Escaping characters in Emacs org-mode

Say I want to escape characters in org-mode, e.g. _ so that org-mode renders the following:
* _TARGET_
In my set up (which I think is the default one) org-mode underlines the word as opposed to rendering _TARGET_
More generally, where can I find information about how to escape characters in Emacs org-mode?
The code and verbatim markup will render the text inside as-is, without interpretation. Therefore, =_TARGET_= will probably work as you intend (you'll also get a different monospace typeface for that word).
With a current Emacs and org-mode you might try
* \under{}TARGET\under{}
If that is not automagically displayed as * _TARGET_ just try C-c C-x \, that should toggle the display of those codings between coding characters and coded character.
(In principle the same as I explained here.)
If you want to break org to interpret some syntax you are using, you will have to ways to do that.
Using escape char. _ is \under and * is \ast, so you can write like this \ast \under{}TARGET\under;
Another way is to use zero width space, its code is 200B, so you can use C-x 8 RET 200b RET to insert a zero width space to break the interpreting.
They work on the latest org on the responding time (latest 9.2).
Alternatively, use the normal shell backslash to escape the characters you want to avoid Org-mode interpreting as markup:
* \_TARGET\_
The backslash characters are visible in your Emacs buffer, but are hidden when exporting - e.g. to HTML or PDF-via-LaTeX.
This escaping works in many other situations, e.g. SR\_1234 to render as SR_1234 during export rather than as a subscript.

How to make part of a word bold in org-mode

How can I make org-mode markup work for a part of a word? For example, I'd like it to work for cases like this:
=Class=es
and this:
/Method/s
Based on my tests it seems like org-mode markup syntax works on complete words only.
These days, there is a way to do this (without using quoted HTML tags):
(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
Explanation
The manual says that org-emphasis-regexp-components can be used to
fine tune what characters are allowed before and after the markup characters [...].
It is a list containing five entries. The first entry lists characters that are allowed to immediately precede markup characters, and the second entry lists characters that are allowed to follow markup characters. By default, letters are not included in either one of these entries. So in order to successfully apply formatting to strings immediately preceded or followed by a letter, we have to add [:alpha:] (which matches any letter) to both entries.
This is what the calls to setcar do. The purpose of the third line is to rebuild the regular expression for emphasis based on the modified version of org-emphasis-regexp-components.
I don't think you can do it so that it shows up in the buffer as bold. If you just need it so that it appears bold when you export it to html, you can use:
th#<b>is is ha#</b>lf bold
See Quoting HTML tags
No, you can't do that. I searched for the same solution before and found nothing. A (very) bad hack is to do something like *Class* es (with a whitespace).
Perhaps you can write a short message to the creator, Carsten Dominik (Homepage), and ask him for a solution. He seems to be a nice guy.
A solution that has not been mentioned is to use a unicode zero width space (U+200B) in between the desired bolded and unbolded parts of a word.
To get the desired bolding of the word "Classes":
Type 'Class*es' in the buffer (without quotes).
Move the cursor between the '*' and 'e' characters.
Press C-x 8 RET (to execute the insert-char command).
Type 'zero width space' (without quotes) and press RET.
Move the cursor to the beginning of the word and insert a '*' character.
The word "Classes" should now have the desired appearance.
Note that there is the possibility that this will cause problems when exporting.
src_latex{\textbf{Class}es and \textit{Method}s}
Building up on the previous excellent answer
I had to modify it a bit in order to make it work with spacemacs. Indeed, from the spacamacs org-layer documentation, available here, we can read
Because of autoloading, calling to org functions will trigger the
loading up of the org shipped with emacs which will induce conflicts.
One way to avoid conflict is to wrap your org config code in a
with-eval-after-load block [...]
So, I put the following lines inside my dotspacemacs/user-config ()
(eval-after-load "org"
'(progn
(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
))

Disabling underscore-to-subscript in Emacs Org-Mode export

When I export to PDF via org-mode (C-c C-e d), any words with underscores end up being partially converted to subscript. How can I prevent this from happening?
I found this article on the subject:
Disabling Underscore subscript in Emacs Tex Mode
However, I either wasn't able to figure out the correct elisp or it simply didn't work. Note, I don't want to change any global font options. I only want this fix to apply to tex/latex/org-mode.
I also found this post, though it didn't work either:
disable subscript superscript raise/lower?
You can disable super/subscripting within an org file by adding the following line:
#+OPTIONS: ^:nil
Check the org manual for more options.
The following command inserts a template containing all the options:
C-c C-e #
I was able to solve the issue by setting the following variable:
(setq org-export-with-sub-superscripts nil)
I think this would be easier: http://orgmode.org/manual/Subscripts-and-superscripts.html
Escape the underscore with a backslash:
Now, escape the _:
You can see this in action here: http://www.railsonmaui.com/blog/2013/04/27/octopress-setup-with-github-and-org-mode/
Use \under (Documentation on The Org Manual: Special symbols)
For example:
text\under{}text
Do you want to prevent subscripts in the onscreen display of the source file or in the text of the output PDF? If the latter, then you want
\usepackage{underscore}
It won't break the use of underscores in maths mode, either.
For individual cases, insert a literal underscore this way:
text text one\textunderscore{}two text
In my case any word that contains an underscore is likely to be a variable name or something similar. I just surround it with = or ~ so that it's treated as such. Then it will be exported accordingly.