emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: ox-latex and small caps links
Date: Wed, 22 Apr 2015 11:08:45 +0200	[thread overview]
Message-ID: <874mo88r8i.fsf@gmx.us> (raw)
In-Reply-To: m27ft5geq3.fsf@block-party.net

Hi,

David Dynerman <david@block-party.net> writes:

> I've been using links to render text in small caps when exporting to
> LaTeX and HTML, e.g.
>
> [[latex:textsc][this is in small caps]]
>
> This worked fine in 8.2.10, but causes an error in latest. When I try to
> export the file to LaTeX, the export fails with:
>
> Unable to resolve link latex:textsc

Perhaps you did not add the latex link type.  You could also use a macro.

I use the following hack, which (tries to) captures words like ThIs, THIS,
or thIS and export is as \textsc{t}h\textsc{i}s, \textsc{this}, or
th\textsc{is}.  It won't manage e.g. (i).

For html you need to add support for a small-caps class.

  (defun rasmus/org-guess-textsc (content backend info)
    "Automatically downcase and wrap all-caps words in textsc.
The function is a bit slow...

TODO: Make the function work with headlines, but without doing it
on subsequent text.

TODO: Add ODT support."
    (if (org-export-derived-backend-p backend 'latex 'html)
        (let* (case-fold-search
               (latexp (org-export-derived-backend-p backend 'latex))
               (wrap (if latexp "\\textsc{%s}"
                         "<span class=\"small-caps\">%s</span>")))
          (replace-regexp-in-string
           "\\w+"
           (lambda (str)
             (if (or (string-equal str (downcase str))
                     (string-equal str (capitalize str)))
                 str
               (replace-regexp-in-string
                "[[:upper:]]+"
                (lambda (x) (format wrap (downcase x)))
                str t t)))
           content t t))
      content))

  (add-to-list 'org-export-filter-plain-text-functions
               'rasmus/org-guess-textsc)

I have also found the slantsc latex package useful for emphases with small
caps.

Here's what I have used for small caps in css.

   body {
       font-family: "Linux Libertine";
       -moz-font-feature-settings:"onum" 1, "kern" 1, "liga" 1;
       -moz-font-feature-settings:"onum=1, kern=1, liga=1";
       -ms-font-feature-settings:"onum" 1, "kern" 1, "liga" 1;
       -o-font-feature-settings:"onum" 1, "kern" 1, "liga" 1;
       -webkit-font-feature-settings:"onum" 1, "kern" 1, "liga" 1;
       font-feature-settings:"onum" 1, "kern" 1, "liga" 1;}

   .small-caps {
       -ms-font-feature-settings: "smcp";
       -moz-font-feature-settings: "smcp";
       -webkit-font-feature-settings: "smcp";
       font-feature-settings: "smcp";
       letter-spacing:.02em;
       font-variant-caps: small-caps;
       text-transform: lowercase;}

Hope it helps,
Rasmus

-- 
I hear there's rumors on the, uh, Internets. . .

      parent reply	other threads:[~2015-04-22  9:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22  0:59 ox-latex and small caps links David Dynerman
2015-04-22  1:27 ` Thomas S. Dye
2015-04-22  1:41   ` David Dynerman
2015-04-22  2:59     ` Thomas S. Dye
2015-04-22  9:08 ` 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=874mo88r8i.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).