4

I'm aware of fonts such as cmr10, cmex10 and cmsy10. Right now I would like to know how to use TeX to produce symbols in the character tables such as http://www.math.union.edu/~dpvc/jsmath/symbols/cmex10.html

Is there a dictionary somewhere on the internet containing how to TeX every symbol in character tables given the font? (i.e. Given '\0x41' and the font cmr10 I want to obtain 'A', given '\0x00' and cmr10 I want to obtain '\textGamma').

P.S. This question is motivated by my attempts to extract text from .tex files. I end up deciding to first convert .tex files to DVI files and then use dviasm to extract the text because it bypasses the need to essentially build another TeX engine.

  • 1
    Have you considered just using the PDF directly, e.g. with pdf2htmlEX ? There's a comparison of other options here. – ShreevatsaR Apr 24 at 3:22
  • @ShreevatsaR No, that does not work for me because despite the fact that the HTML is almost perfect I can't extract any characters at all. – Ying Zhou Apr 24 at 4:03
  • 1
    I am able to copy characters from e.g. this demo. Of course it only works when they are present in the original PDF. – ShreevatsaR Apr 24 at 4:36
  • @ShreevatsaR Well, I need to automate the process. Moreover by "copying characters" I include copying non-Latin characters and things such as \mathcal{A} as well. – Ying Zhou Apr 24 at 5:16
4

An adjunct to the "Comprehensive LaTeX symbols list" is the "rawtables" pdf file that contains font tables for all the fonts covered by that list, arranged in alphabetical order. The font table arrangement shows the location in the font presented to TeX; it does not identify the glyphs by Unicode ID.

The collection is on CTAN: http://mirrors.ctan.org/info/symbols/comprehensive and the pdf listing comes in either lettersize or a4.

Despite the "LaTeX" in the title, these fonts can be used also with plain TeX.

  • Really thanks! I have read it! I still need to find an actual list of TeX code that can generate the respective glyphs. It seems that I need to manually do that. I will do that for at least the most popular fonts. – Ying Zhou Apr 24 at 4:12
4

While the user specifies TeX (for Plain TeX, see SUPPLEMENT), these tables are most easily obtainable via LaTeX, in the format described by the OP at http://www.math.union.edu/~dpvc/jsmath/symbols/cmex10.html

\documentclass{article}
\usepackage{fonttable}
\begin{document}
\fonttable{cmex10}
\end{document}

enter image description here

The same font table may be alternately obtained via \xfonttable{OMX}{cmex}{m}{n}.

To answer the OP's specific question about the letter A in cmr10,

\documentclass{article}
\usepackage{fonttable}
\begin{document}
\fonttable{cmr10}
\end{document}

enter image description here

Just remember though, that for a given encoding scheme, one knows where to find various glyphs, even without printing the font table, especially for standard glyphs such as those available in ASCII.


SUPPLEMENT

For the Plain TeX alternative (fontchart.tex, found at https://ctan.org/pkg/fontchart?lang=en), here is the result for cmr10:

enter image description here

enter image description here

  • Really thanks for your detailed answer! However I need to identify more than just the glyphs even though they are also something I can only identify manually now. The TeX code that can generate them also need to be identified automatically if possible. – Ying Zhou Apr 24 at 4:06
  • 1
    @YingZhou It depends on which direction of decode you need to go. For example, looking at the cmr table, I can see that \fontfamily{cmr}\fontencoding{OT1}\selectfont\char"03 will give me a capital \lambda. On the other hand, if visually presented with a $\Lambda$ and then to figure out what font family it belongs to, which font encloding, and which glyph slot, that is a different problem. – Steven B. Segletes Apr 24 at 9:55
3

LaTeX Font Encodings contains font tables for every legacy LaTeX encoding in common use. The modern toolchain with fontspec simply uses the Unicode encoding (under the alias TU).

If you want to be able to copy-and-paste, or otherwise automatically convert, text from a PDF document compiled from LaTeX source, your best bet is to use unicode-math. Then, all your glyphs are already encoded in Unicode.

A font using a non-standard encoding (such as U) should come with documentation. For example, the masfonts manual comes with tables of all its fonts in an appendix.

  • Really thanks for the book! I got its TeX code and am trying to figure out how to let them print the code (e.g. '\rightarrow') in addition to the glyphs (e.g. a right arrow). – Ying Zhou Apr 24 at 4:08
3

You could look at the tex4ht files. There are lot of mappings of slot positions to unicode in the hf-fonts. E.g. \texmf-dist\tex4ht\ht-fonts\unicode\cm\cmex.htf contains mappings like this:

'∘' ''  112
'∘' ''  113
'∘' ''  114
'∘' ''  115
'∘' ''  116
'│' ''  117
'┌' ''  118
'║' ''  119
'↑' ''  120
'↓' ''  121

Mappings between slot positions and (la)tex commands are imho much more difficult to optain and maintain as every package/document can change or add commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.