Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\DocumentMetadata results in incorrect version number of pdfTeX #1186

Closed
stone-zeng opened this issue Mar 15, 2023 · 3 comments · Fixed by #1187
Closed

\DocumentMetadata results in incorrect version number of pdfTeX #1186

stone-zeng opened this issue Mar 15, 2023 · 3 comments · Fixed by #1187
Assignees
Labels
bug Something isn't working

Comments

@stone-zeng
Copy link
Contributor

stone-zeng commented Mar 15, 2023

Brief outline of the bug

When using the \DocumentMetadata command, the producer information in pdf metadata is incorrect: pdftex-1.40.25 becomes pdftex-1.4.25 (with a missing zero).

Minimal example showing the bug

Use pdflatex or pdflatex-dev to compile the following code:

\DocumentMetadata{}
\documentclass{article}
\begin{document}
Hello, world!
\end{document}

Then check the metadata of the generated PDF file with pdfinfo:

Creator:        LaTeX
Producer:       pdftex-1.4.25  <-- should be pdftex-1.40.25
CreationDate:   Wed Mar 15 12:09:07 2023
ModDate:        Wed Mar 15 12:09:07 2023
Tagged:         no
Form:           none
Pages:          1
Encrypted:      no
Page size:      612 x 792 pts (letter) (rotated 0 degrees)
File size:      24069 bytes
Optimized:      no
PDF version:    1.5

Log file (required) and possibly PDF file

1.log
1.pdf

Version info

% pdflatex --version
pdfTeX 3.141592653-2.6-1.40.25 (TeX Live 2023)
kpathsea version 6.3.5
Copyright 2023 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.39; using libpng 1.6.39
Compiled with zlib 1.2.13; using zlib 1.2.13
Compiled with xpdf version 4.04
@muzimuzhi
Copy link
Contributor

muzimuzhi commented Mar 15, 2023

a latex3 issue, what stored in \c_sys_engine_version_str is wrong. Evidence of how it's used by \DocumentMetadata{}.

(assuming this will be transferred to latex3 repo)

Update: For pdftex that str holds the expansion of

{ pdftex }
{
\fp_eval:n { round(\int_use:N \tex_pdftexversion:D / 100 , 2) }
.
\tex_pdftexrevision:D
}

here \fp_eval:n { round(1.4, 2) } is expected to be 1.40, but gives 1.4.

Update 2: It seems \fp_eval:n and other fp evaluators always trim non-significant trailing zeros. How about inserting the dot with macro expansion like

% will fail if pdftex major version number has two or more digits
\exp_last_unbraced:Nno \use_ii_i:nn . { \int_use:N \tex_pdftexversion:D }
.
\tex_pdftexrevision:D

or if one prefers calculations

% relies on the assumption that the miner version is always two digits, 
% which is documented in luatex manual but not in pdftex manual
\int_div_truncate:nn { \tex_pdftexversion:D } { 100 }
.
\int_mod:nn { \tex_pdftexversion:D } { 100 }
.
\tex_pdftexrevision:D

Update 3: luatex has similar problem

{ luatex }
{
\fp_eval:n { round(\int_use:N \tex_luatexversion:D / 100, 2) }
.
\tex_luatexrevision:D
}

@FrankMittelbach FrankMittelbach transferred this issue from latex3/latex2e Mar 15, 2023
@FrankMittelbach FrankMittelbach added the bug Something isn't working label Mar 15, 2023
@muzimuzhi
Copy link
Contributor

or if one prefers calculations

% relies on the assumption that the miner version is always two digits, 
% which is documented in luatex manual but not in pdftex manual
\int_div_truncate:nn { \tex_pdftexversion:D } { 100 }
.
\int_mod:nn { \tex_pdftexversion:D } { 100 }
.
\tex_pdftexrevision:D

Just realized this second suggestion adds no additional assumption on value of \tex_pdftexversion:D, compared to the current fp way.

@josephwright josephwright self-assigned this Mar 15, 2023
@josephwright
Copy link
Member

% relies on the assumption that the miner version is always two digits,
% which is documented in luatex manual but not in pdftex manual

The pdfTeX manual says 'Returns the version of pdfTeX multiplied by 100', so I think we are allowed to assume that the lowest two digits are the decimal part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants