emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: New LaTeX exporter, link to \ref
Date: Sun, 16 Sep 2012 22:42:19 +0200	[thread overview]
Message-ID: <80lig9og2c.fsf@somewhere.org> (raw)
In-Reply-To: m17grtlu6v.fsf@tsdye.com

Hi Thomas,

Thomas S. Dye wrote:
>> I use the following instead (_ character stands for the non-breaking
>> space):
>> #+begin_src emacs-lisp
>> (defun ngz-latex-filter-nobreaks (text backend info)
>>   "Ensure \"_\" are properly handled in Beamer/LaTeX export."
>>   (when (memq backend '(e-beamer e-latex))
>>     (replace-regexp-in-string "_" "~" text)))
>> (add-to-list 'org-export-filter-plain-text-functions
>>              'ngz-latex-filter-nobreaks)
>> #+end_src
> Thanks very much for the filter, which makes for an aesthetically
> pleasing org buffer.  I changed the underscore to a non-breaking
> space character in the call to replace-regexp-in-string and now get
> tildes in my LaTeX export.

I use this:

#+begin_src emacs-lisp
  ;; replace space by nobreak-space where it fits well
  (defun my/replace-space-before-colon ()
    "Replace space by nobreak-space in front of a colon."
    (cond ((eq (char-before) ?\ ) ;; normal space
           (backward-delete-char 1)
           (cond ((equal mode-name "PDFLaTeX")
                  (insert "~:"))
                 ((equal mode-name "Org")
                  (if (and (fboundp 'org-in-src-block-p)
                      (insert " :")
                    (insert " :")))
                 ;; FIXME Don't put a nobreak space when specifying Org
                 ;; Babel properties (such as :exports both)
                  (insert " :")))) ;; non-breaking space
          ;; remove nobreak-space if two colons are put one after the
          ;; other (for terms and definitions in Org)
          ((and (eq (char-before) ?\:)
                (eq (char-before (- (point) 1)) ?\ ))
           (backward-delete-char 2)
           (insert " ::")) ;; normal space

           (insert ":"))

  ;; French typography
  (defun my/nobreak-keys ()
    "If any, replace space in front of colons, question marks, exclamation
  marks, etc. to avoid line break problems."
    (local-set-key ":" 'my/replace-space-before-colon))

  (add-hook 'text-mode-hook 'my/nobreak-keys)
  (add-hook 'message-mode-hook 'my/nobreak-keys)

in order to have real nbsp as well in my Org buffer. They aren't translated
neither to HTML nor to LaTeX (they're simply copied across), allowing for
consistent view in all the buffers (source + outputs).

Best regards,

Sebastien Vauban

      reply	other threads:[~2012-09-16 20:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-16  1:02 New LaTeX exporter, link to \ref Thomas S. Dye
2012-09-16  7:40 ` Nicolas Goaziou
2012-09-16 18:05   ` Thomas S. Dye
2012-09-16 20:42     ` Sebastien Vauban [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80lig9og2c.fsf@somewhere.org \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).