Add \usepackage{cmap} as default LaTeX class in ox-latex (was: org exported pdf files)

2022-09-28 Thread Ihor Radchenko
Max Nikulin  writes:

> On 28/09/2022 10:07, Ihor Radchenko wrote:
>> Max Nikulin writes:
>> 
>>> - What TeX engine do you use? E.g. for PdfLaTeX it may be necessary to
>>> add \usepackage{cmap} immediately after \documentclass. Unicode engines
>>> like LuaTeX likely do not require such trick.
>> 
>> I am wondering if having cmap should be a good default in general.
>> Not just for accessibility.
>
> For me it must have, but I am a rare person on this mail list who is 
> happy with the Computer Modern font (actually cm-super Type 1 font). I 
> have never tried .ttf fonts with PdfLaTeX and I am unaware of effect of 
> \usepackage{cmap} in that case.

May others familiar with LaTeX comment on this?
If it is safe to add cmap to default LaTeX template, I see no reason why
we should not.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



Re: Add \usepackage{cmap} as default LaTeX class in ox-latex (was: org exported pdf files)

2022-09-29 Thread Max Nikulin

On 29/09/2022 11:12, Ihor Radchenko wrote:

Max Nikulin writes:


On 28/09/2022 10:07, Ihor Radchenko wrote:

Max Nikulin writes:


- What TeX engine do you use? E.g. for PdfLaTeX it may be necessary to
add \usepackage{cmap} immediately after \documentclass. Unicode engines
like LuaTeX likely do not require such trick.


I am wondering if having cmap should be a good default in general.
Not just for accessibility.


For me it must have, but I am a rare person on this mail list who is
happy with the Computer Modern font (actually cm-super Type 1 font). I
have never tried .ttf fonts with PdfLaTeX and I am unaware of effect of
\usepackage{cmap} in that case.


May others familiar with LaTeX comment on this?
If it is safe to add cmap to default LaTeX template, I see no reason why
we should not.


It seems something changed during last decade. I have not tried default 
Type3 raster fonts (I do not remember if it is possible to disable 
cm-super without uninstalling it), but at least with cm-super installed, 
the cmap package is not necessary to have Cyrillic text properly encoded 
in PDF files, not to mention ASCII. I have tried utf8 and cp1251 options 
of inputenc.


However with cmap more math characters get correct unicode symbols

\[ \forall \delta \exists \epsilon \ne t \]

I tried to search for problems that may cause cmap. There is no 
incompatibility with \usepackage[pdfa=true]{hyperref} anymore

https://tex.stackexchange.com/questions/64585/incompatibilities-of-cmap-with-fontenc-hyperref
(side note: the answer marked as accepted is incorrect). So I hope, it 
is safe to use this package for PdfLaTeX.


I have noticed mmap package intended to improve math representation
https://tex.stackexchange.com/questions/64409/proper-use-of-cmap-and-mmap
With the dumb example provided above I have not noticed difference 
between cmap and \usepackage[noTeX]{mmap}. I am unsure when TeX commands 
may be preferred to Unicode characters as it works for default mmap 
configuration.


There is a chance that mmap is not installed in the system since it is 
provided by "extra" system package in Ubuntu:
texlive-latex-recommended: 
/usr/share/texlive/texmf-dist/tex/latex/cmap/cmap.sty

texlive-latex-extra: /usr/share/texlive/texmf-dist/tex/latex/mmap/mmap.sty
It should be possible to detect availability of mmap.sty in runtime 
using kpsewhich command.


So when I was writing that cmap is must have for me, I was not aware 
that nowadays PDF files generated from LaTeX source have mostly properly 
encoded text even without this package, in the past attempt to copy text 
resulted in some garbage.