emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: inter-word space in org -> latex
Date: Tue, 22 Sep 2015 22:59:58 +0200	[thread overview]
Message-ID: <878u7ykw4x.fsf@gmx.us> (raw)
In-Reply-To: 87oagu2n5h.fsf@mbork.pl

Marcin Borkowski <mbork@mbork.pl> writes:

> ;; Convert single spaces after periods etc. to "\ " when exporting to LaTeX
>
> (defun my-latex-filter-nonfrenchspacing (text backend info)
>   "Convert single spaces after dots to \"\ \"."
>   (when (and (org-export-derived-backend-p backend 'latex)
> 	     sentence-end-double-space)
>     (replace-regexp-in-string
>      (concat "\\(" sentence-end-base "\\)"
> 	     "[ \u00a0]\\([^ \t\u00a0\n]\\)")
>      "\\1\\\\ \\2" text)))
>
> (add-to-list 'org-export-filter-plain-text-functions
> 	     'my-latex-filter-nonfrenchspacing)
>
> It is a bit simplistic (after all, I wrote it just now in 15 minutes),
> but it seems to work fine.  It makes a few assumptions, though.  One of
> them is that you don't mess with sentence-end-base too much: I assumed
> that there are no non-shy groups there.  (By default there are not, and
> I don't see any reason for them to be there, but what do I know.)  Also,
> I assume that for the period to /not/ end the sentence, it should be
> followed by one space and something non-spacey.

Here'a an alternative implementation with other limitation, e.g. only
looking at [A-Z] for capitals:

       http://permalink.gmane.org/gmane.emacs.orgmode/101176

> Also, note that while Emacs' way of differentiating between
> a sentence-ending period and a non-sentence-ending period are fairly
> simple, (La)TeX's rules are a bit more complicated (look up "space
> factor" in The TeXbook).  For instance, LaTeX assumes that a period
> after a capital letter /never/ ends the sentence, and you have to use \@
> before such period to change that.  The algorithm TeX uses is really
> clever, and can be (ab)used in funny ways to do funny stuff in
> low-level, hackish TeX ways (been there, done that - for instance, when
> I once reimplemented the theorem-like environments, I used space factor
> to make sure that if a theorem begins with an enumeration, it looks
> fine.  The "standard" LaTeX implementation of theorem-like environments
> is kind of crazy, even if it works in typical cases.  Try typesetting
> a theorem with a long optional argument in a narrow column and see what
> happens, for instance.).

But isn't a lot of the cruft from TeX "fixed" in LaTeX.  E.g. I believe
the correct space is automatically used after emphasis.


> TL;DR: just use \frenchspacing.  Everyone will be happier.

Or not.

-- 
The Kids call him Billy the Saint

      reply	other threads:[~2015-09-22 21:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14 14:42 inter-word space in org -> latex Dan Griswold
2015-09-14 16:50 ` Rasmus
2015-09-16 15:32   ` Dan Griswold
2015-09-14 16:54 ` Suvayu Ali
2015-09-16 15:33   ` Dan Griswold
2015-09-22 20:17 ` Marcin Borkowski
2015-09-22 20:51   ` Marcin Borkowski
2015-09-22 20:59     ` Rasmus [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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=878u7ykw4x.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).