Print 'system information' in LaTeX doc
A starting point. The following example extracts information that is available at TeX macro level (code parts are taken from hyperref
):
\documentclass{article}
\usepackage{hologo}
\usepackage{ifluatex}
\usepackage{ifxetex}
\usepackage{ifvtex}
\makeatletter
\newcommand*{\InfoLaTeX}{%
\hologo{\fmtname} \textless\fmtversion\textgreater
}
\newcommand*{\InfoTeX}{%
\ifxetex
\hologo{XeTeX}-%
\the\XeTeXversion\XeTeXrevision
\else
\ifluatex
\hologo{LuaTeX}-%
\begingroup
\count@=\luatexversion
\divide\count@ by 100 %
\edef\x{\the\count@}%
\count@=-\x\relax
\multiply\count@ by 100 %
\advance\count@ by \luatexversion
\x.\the\count@.\luatexrevision
\endgroup
\else
\@ifundefined{pdftexversion}{%
\ifvtex
\hologo{VTeX}%
\@ifundefined{VTeXversion}{%
}{%
\begingroup
\count@\VTeXversion
\divide\count@ 100 %
\space v\the\count@
\multiply\count@ -100 %
\advance\count@\VTeXversion
.\two@digits\count@
\endgroup
}%
\else
\hologo{TeX}%
\fi
}{%
\hologo{pdfTeX}-%
\ifnum\pdftexversion<100 %
\the\pdftexversion.\pdftexrevision
\else
\ifnum\pdftexversion<130 %
\expandafter\@car\the\pdftexversion\@empty\@nil.%
\expandafter\@cdr\the\pdftexversion\@empty\@nil
\pdftexrevision
\else
\expandafter\@car\the\pdftexversion\@empty\@nil.%
\expandafter\@cdr\the\pdftexversion\@empty\@nil.%
\pdftexrevision
\fi
\fi
}%
\fi
\fi
}
\makeatother
\begin{document}
\begin{tabular}{@{}ll@{}}
Compiled by: & \InfoTeX \\
\hologo{LaTeX} version: & \InfoLaTeX \\
\end{tabular}
\end{document}
A script could gather the other data (OS, ...) and write definitions in a .tex
file
that can be read by the TeX run.
If you are willing to use a shell-escape (i.e. compile with 'latex --shell-escape'), you can probably use 'uname' on Unix-like platforms and on Cygwin...
\documentclass{article}
\makeatletter
% redefine \author as \maketitle clears \@author...
\let\oldAuthor=\author
\renewcommand{\author}[1]{\oldAuthor{#1}\gdef\ShowAuthor{#1}}
\newcommand{\ShowOsVersion}{%
\immediate\write18{\unexpanded{foo=`uname -a` && echo "\\verb+${foo}+" > tmp.tex}}%
\input{tmp}\immediate\write18{rm tmp.tex}%
}
\makeatother
\title{This is a Document}
\author{John Smith}
\begin{document}
\maketitle
Compiled on: \today
Compiled by: \ShowAuthor
OS version: \ShowOsVersion
\LaTeX{} version: \LaTeXe~\fmtversion
\end{document}
If you want something similar on Windows, I think you could use something along the lines of...
\immediate\write18{systeminfo | findstr /B /C:"OS Name" /C:"OS Version" > tmp.tex}
and maybe restructure slightly - for instance, you'll need to remove the "OS Version:" from the main text because this 'systeminfo' command outputs more than just the version number - for me it outputs
OS Name: Microsoft Windows 7 Professional
OS Version: 6.1.7601 Service Pack 1 Build 7601