[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minor tip] "TeXify" strings "TeX" and "LaTeX" when exporting to HTML

From: Juan Manuel Macías
Subject: [minor tip] "TeXify" strings "TeX" and "LaTeX" when exporting to HTML
Date: Fri, 15 Oct 2021 16:56:01 +0000

Hi all,

I wrote this simple filter for my blogs, which formats "TeX" and "LaTeX"
strings in the TeX 'typographic' style (or something similar).

First, these variables:

#+begin_src emacs-lisp
  (setq my/tex-html-string "<span style=\"font-family:serif;\">T<span
  (setq my/latex-html-string "<span style=\"font-family:serif;\">L<span

Of course, the strings can be improved. Another alternative would be to use the 
wikipedia images:

style=\"vertical-align: -1.005ex; width:5.094ex; height:2.843ex;\"

style=\"vertical-align: -1.005ex; width:7.107ex; height:2.843ex;\"

The function:

#+begin_src emacs-lisp
  (defun my/latex-string-html-filter (text backend info)
    (when (org-export-derived-backend-p backend 'html)
      (let ((case-fold-search nil))
          (insert text)
            (goto-char (point-min))
            (while (re-search-forward "\\([^La]\\)TeX" nil t)
              (replace-match (concat "\\1" my/tex-html-string))))
            (goto-char (point-min))
            (while (re-search-forward "LaTeX" nil t)
              (replace-match my/latex-html-string)))
          (setq text (buffer-string))))))

And, finally:

#+begin_src emacs-lisp
  (add-to-list 'org-export-filter-plain-text-functions 

Fun fact. Donald Knuth explains in the first chapter of his /TeX book/,
"The Name of the Game", the origin of the term TeX, and why it is
formatted that way:

English words like `technology' stem from a Greek root beginning with
the letters τεχ...; and this same Greek word means /art/ as well as


Insiders pronounce the χ of TeX as a Greek chi, not as an `x', so that
TeX rhymes with the word blecchhh. It's the `ch' sound in Scottish words
like /loch/ or German words like /ach/; it's a Spanish `j' and a Russian


On the other hand, it's important to notice another thing about TeX's
name: The `E' is out of kilter. This logo displaced `E' is a reminder
that TeX is about typesetting, and it distinguishes TeX from other
system names. [...] The correct way to refer to TeX in a computer file,
or when using some other medium that doesn't allow lowering of the `E',
is to type `TeX'. Then there will be no confusion with similar names,
and people will be primed to pronounce everything properly.

Best regards,

Juan Manuel 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]