emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: orgmode <emacs-orgmode@gnu.org>
Subject: [minor tip] "TeXify" strings "TeX" and "LaTeX" when exporting to HTML
Date: Fri, 15 Oct 2021 16:56:01 +0000	[thread overview]
Message-ID: <87ilxyns66.fsf@posteo.net> (raw)

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
  style=\"vertical-align:-0.4ex;font-size:smaller;\">E</span>X</span>")
  
  (setq my/latex-html-string "<span style=\"font-family:serif;\">L<span
  style=\"vertical-align:0.5ex;font-size:smaller;margin-left:-0.3em;\">A</span>T<span
  style=\"vertical-align:-0.4ex;font-size:smaller;\">E</span>X</span>")
#+end_src

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

<img
src=\"https://wikimedia.org/api/rest_v1/media/math/render/svg/45c5b62b0f454f4ed8caa486d6d3cd0e0c065232\"
style=\"vertical-align: -1.005ex; width:5.094ex; height:2.843ex;\"
alt=\"TeX\"/>

<img
src=\"https://wikimedia.org/api/rest_v1/media/math/render/svg/fa952935eafe23237c5a52922460c192fde88435\"
style=\"vertical-align: -1.005ex; width:7.107ex; height:2.843ex;\"
alt=\"LaTeX\"/>

The function:

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

And, finally:

#+begin_src emacs-lisp
  (add-to-list 'org-export-filter-plain-text-functions #'my/latex-string-html-filter)
#+end_src

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:

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

[...]

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
`kh'. 

[...]

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.
#+end_quote

Best regards,

Juan Manuel 


                 reply	other threads:[~2021-10-15 16:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87ilxyns66.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --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).