emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [minor tip] "TeXify" strings "TeX" and "LaTeX" when exporting to HTML
@ 2021-10-15 16:56 Juan Manuel Macías
  0 siblings, 0 replies; only message in thread
From: Juan Manuel Macías @ 2021-10-15 16:56 UTC (permalink / raw)
  To: orgmode

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 #'my/latex-string-html-filter)

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 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-15 16:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-15 16:56 [minor tip] "TeXify" strings "TeX" and "LaTeX" when exporting to HTML Juan Manuel Macías

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