Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've used TeX quite a bit before but am getting back into it at the moment.

I want to print a document details page with info such as:

Compiled on:
Compiled by:
OS version:
LaTeX version:

Obviously the first two are easy (\today and \author). Are there similar commands for the others? Or is there a package available which could manage this?

share|improve this question
    
Welcome to TeX.SX. Note that you don't have to sign with your name since it automatically appears in the lower right corner of your post. A tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button ({}). –  Claudio Fiandrino Oct 19 '12 at 15:04
7  
LaTeX has no notion about what operating system it runs on; however you can use the ifplatform package to set different phrases depending on the operating system. The version of LaTeX is just a date that you can get with \fmtversion, for instance \LaTeX{} version: \LaTeXe~\fmtversion –  egreg Oct 19 '12 at 15:12
    
Do you want to print this information on papier or to have it stored in the pdf file? With package hyperref you can include this information in the pdf an check them with a pdf reader (File -> Properties). –  Kurt Oct 19 '12 at 15:47
add comment

3 Answers

up vote 10 down vote accepted

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
share|improve this answer
    
Welcome to TeX.sx! –  Kurt Oct 19 '12 at 17:03
    
I'm getting this error: line 1: Text line contains an invalid character line 1: You can't use `macro parameter character #' in horizontal mode erb+Linux vaio 3.0.0-16-generic-pae # –  Sigur Oct 19 '12 at 23:21
add comment

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.

Result

share|improve this answer
add comment

A workable approach (at least once your document has grown in scale beyond a single source file) is to use a shell script or batch file to discover and write the information you desire into a file named something like sysinfo.tex. You then reference that in your main document.

I've used this technique mostly for documents that are already heavily machine generated where I also include revision information for the generating program as well as information from the version control system, but there's no reason it can't be done for more ordinary documents.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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