org-latex.el: New defcustom `org-export-latex-quotes' to control quotes.
* org-latex.el (org-export-latex-quotes): New defcustom. (org-export-latex-quotation-marks): Use it. This allows users to define what quotes they want to use as a replacement of english double-quotes while exporting to LaTeX. In particular, if you use the csquote package, you can configure Org to output something like \endquote{some quoted text} instead of "some quoted text". Thanks to Frederik for bringing this issue up, and to Thomas S. Dye, Nick Dokos and Stefan Nobis for elaborating this solution.
This commit is contained in:
parent
9fc6daa3d2
commit
2b9afb9e63
|
@ -321,6 +321,32 @@ will be filled with the link, the second with its description."
|
||||||
:group 'org-export-latex
|
:group 'org-export-latex
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
|
(defcustom org-export-latex-quotes
|
||||||
|
'(("fr" ("\\(\\s-\\|[[(]\\)\"" . "«~") ("\\(\\S-\\)\"" . "~»") ("\\(\\s-\\|(\\)'" . "'"))
|
||||||
|
("en" ("\\(\\s-\\|[[(]\\)\"" . "``") ("\\(\\S-\\)\"" . "''") ("\\(\\s-\\|(\\)'" . "`")))
|
||||||
|
"Alist for quotes to use when converting english double-quotes.
|
||||||
|
|
||||||
|
The CAR of each item in this alist is the language code.
|
||||||
|
The CDR of each item in this alist is a list of three CONS:
|
||||||
|
- the first CONS defines the opening quote;
|
||||||
|
- the second CONS defines the closing quote;
|
||||||
|
- the last CONS defines single quotes.
|
||||||
|
|
||||||
|
For each item in a CONS, the first string is a regexp
|
||||||
|
for allowed characters before/after the quote, the second
|
||||||
|
string defines the replacement string for this quote."
|
||||||
|
:group 'org-export-latex
|
||||||
|
:type '(list
|
||||||
|
(cons :tag "Opening quote"
|
||||||
|
(string :tag "Regexp for char before")
|
||||||
|
(string :tag "Replacement quote "))
|
||||||
|
(cons :tag "Closing quote"
|
||||||
|
(string :tag "Regexp for char after ")
|
||||||
|
(string :tag "Replacement quote "))
|
||||||
|
(cons :tag "Single quote"
|
||||||
|
(string :tag "Regexp for char before")
|
||||||
|
(string :tag "Replacement quote "))))
|
||||||
|
|
||||||
(defcustom org-export-latex-tables-verbatim nil
|
(defcustom org-export-latex-tables-verbatim nil
|
||||||
"When non-nil, tables are exported verbatim."
|
"When non-nil, tables are exported verbatim."
|
||||||
:group 'org-export-latex
|
:group 'org-export-latex
|
||||||
|
@ -1624,21 +1650,18 @@ links, keywords, lists, tables, fixed-width"
|
||||||
|
|
||||||
(defun org-export-latex-quotation-marks ()
|
(defun org-export-latex-quotation-marks ()
|
||||||
"Export quotation marks depending on language conventions."
|
"Export quotation marks depending on language conventions."
|
||||||
(let* ((lang (plist-get org-export-latex-options-plist :language))
|
(mapc (lambda(l)
|
||||||
(quote-rpl (if (equal lang "fr")
|
(goto-char (point-min))
|
||||||
'(("\\(\\s-\\)\"" "«~")
|
|
||||||
("\\(\\S-\\)\"" "~»")
|
|
||||||
("\\(\\s-\\)'" "`"))
|
|
||||||
'(("\\(\\s-\\|[[(]\\)\"" "``")
|
|
||||||
("\\(\\S-\\)\"" "''")
|
|
||||||
("\\(\\s-\\|(\\)'" "`")))))
|
|
||||||
(mapc (lambda(l) (goto-char (point-min))
|
|
||||||
(while (re-search-forward (car l) nil t)
|
(while (re-search-forward (car l) nil t)
|
||||||
(let ((rpl (concat (match-string 1)
|
(let ((rpl (concat (match-string 1)
|
||||||
(org-export-latex-protect-string
|
(org-export-latex-protect-string
|
||||||
(copy-sequence (cadr l))))))
|
(copy-sequence (cdr l))))))
|
||||||
(org-if-unprotected-1
|
(org-if-unprotected-1
|
||||||
(replace-match rpl t t))))) quote-rpl)))
|
(replace-match rpl t t)))))
|
||||||
|
(cdr (or (assoc (plist-get org-export-latex-options-plist :language)
|
||||||
|
org-export-latex-quotes)
|
||||||
|
;; falls back on english
|
||||||
|
(assoc "en" org-export-latex-quotes)))))
|
||||||
|
|
||||||
(defun org-export-latex-special-chars (sub-superscript)
|
(defun org-export-latex-special-chars (sub-superscript)
|
||||||
"Export special characters to LaTeX.
|
"Export special characters to LaTeX.
|
||||||
|
|
Loading…
Reference in New Issue