在 XeTeX 中计算文件内容的 md5sum

在 XeTeX 中计算文件内容的 md5sum

PdfTeX 有\pdfmdfivesum{...}\pdfmdfivesum file {...}分别用于内联文本和外部文件内容。

另一方面,XeTeX 似乎仅提供\mdfivesum。有没有办法在 XeTeX 中计算文件的 md5sum?

\documentclass{article}
\usepackage{ifxetex}

\begin{document}

%for text
\ifxetex
  \mdfivesum{Hello World!}
\else
  \pdfmdfivesum{Hello World!}
\fi

%for file (content)
\ifxetex
  %% ??? \filemdfivesum{\jobname.tex} ??? %%
\else
  \pdfmdfivesum file {\jobname.tex}
\fi

\end{document}

答案1

语法使用file与 pdftex 中一样,

\documentclass{article}
\usepackage{ifxetex}

\begin{document}

%for text
\ifxetex
  \mdfivesum{Hello World!}
\else
  \pdfmdfivesum{Hello World!}
\fi

%for file (content)
\ifxetex
  \mdfivesum file {\jobname.tex}
  \typeout{ xetex \mdfivesum file {\jobname.tex}}
\else
  \pdfmdfivesum file {\jobname.tex}
  \typeout{pdftex \pdfmdfivesum file {\jobname.tex}}
\fi


\end{document}

生成(至少在 texlive 2016 中)日志

$ xelatex qq184
This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./qq184.tex
LaTeX2e <2016/03/31> patch level 1
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(/home/davidc/texmf/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/home/davidc/texmf/tex/latex/base/size10.clo))
(/usr/local/texlive/2016/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(./qq184.aux)
 xetex 886540D667C448267B1AC7A23BF6DB36
[1] (./qq184.aux) )
Output written on qq184.pdf (1 page).
Transcript written on qq184.log.

相关内容