Generalproblem with \def\fileversion, \def\filedate, and setspace

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
lauraf
Posts: 29
Joined: Tue Jan 13, 2009 12:44 pm

problem with \def\fileversion, \def\filedate, and setspace

Post by lauraf »

Hi all,

I have been using \def\fileversion and \def\filedate as illustrated here:

Code: Select all

\documentclass[a4paper, 11pt, final]{article}

% ----------------------------------------------------------------------
% HISTORY
% ----------------------------------------------------------------------
\def\fileversion{v1.0}
\def\filedate{2010/04/22}
% ----------------------------------------------------------------------

% ----------------------------------------------------------------------
% PACKAGES
% ----------------------------------------------------------------------

% general
\usepackage[english]{babel}
\usepackage{setspace}
	%\singlespacing
	%\onehalfspacing
	\doublespacing
	%\setstretch{1.1}
% ----------------------------------------------------------------------


\title{Minimum working example%
\thanks{Version \fileversion, last revised \filedate.}} 

\date{\today}

\begin{document}
\maketitle

Hello!

\end{document}
Today I have added the package setspace to tweak the line spacing, and now \def\fileversion and \def\filedate return the corresponding information from setspace.sty rather than the information relating to my file :o

Any ideas on how to fix this? Or does anybody know a better way to set the date and number for the current file version?

Many thanks,
Laura
Last edited by lauraf on Fri Apr 23, 2010 5:58 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

problem with \def\fileversion, \def\filedate, and setspace

Post by frabjous »

Either put the history section after the packages section like so:

Code: Select all

\documentclass[a4paper, 11pt, final]{article}
% ----------------------------------------------------------------------
% PACKAGES
% ----------------------------------------------------------------------

% general
\usepackage[english]{babel}
\usepackage{setspace}
   %\singlespacing
   %\onehalfspacing
   \doublespacing
   %\setstretch{1.1}
% ----------------------------------------------------------------------

% ----------------------------------------------------------------------
% HISTORY
% ----------------------------------------------------------------------
\def\fileversion{v1.0}
\def\filedate{2010/04/22}
% ----------------------------------------------------------------------


\title{Minimum working example%
\thanks{Version \fileversion, last revised \filedate.}}

\date{\today}

\begin{document}
\maketitle

Hello!

\end{document}
Or use different command names:

Code: Select all

\documentclass[a4paper, 11pt, final]{article}
% ----------------------------------------------------------------------
% HISTORY
% ----------------------------------------------------------------------
\def\myfileversion{v1.0}
\def\myfiledate{2010/04/22}
% ----------------------------------------------------------------------

% ----------------------------------------------------------------------
% PACKAGES
% ----------------------------------------------------------------------

% general
\usepackage[english]{babel}
\usepackage{setspace}
   %\singlespacing
   %\onehalfspacing
   \doublespacing
   %\setstretch{1.1}
% ----------------------------------------------------------------------

\title{Minimum working example%
\thanks{Version \myfileversion, last revised \myfiledate.}}

\date{\today}

\begin{document}
\maketitle

Hello!

\end{document}
You might consider using \today instead of \filename anyway, since presumably you'd be editing it and building to PDF (or PS or DVI or whatever) in on the same days anyway.

Also I personally tend to use \newcommand and/or \renewcommand rather than \def if using LaTeX rather than plain TeX, but I guess it doesn't matter much for these purposes.
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: problem with \def\fileversion, \def\filedate, and setspa

Post by josephwright »

\filedate and \fileversion are used by a number of packages, and are therefore "scracth" values. Pick different macro names: \MyFileDate and \MyFileVersion, for example.
Joseph Wright
lauraf
Posts: 29
Joined: Tue Jan 13, 2009 12:44 pm

Re: problem with \def\fileversion, \def\filedate, and setspa

Post by lauraf »

Great, thank you very much for the hints :)

Laura
Post Reply