13

I'd like to to surface subversion revision numbers for use in the contents of my document. svninfo and svn packages rely on svn keyword substitution to accomplish this, but I get this error when I try it:

Error line 6 ! Missing $ inserted.

Here's the entire document that causes this:

\documentclass{article}
\usepackage{svninfo}

\begin{document}
\svnInfo $Id: doc.tex 8 2013-04-11 19:37:31Z User Name $ %<= Id keyword substituted by svn  

\end{document}

The usual suggested remedies for this error are to escape the $ like this: \$ However, no combination of escaped and non-escaped $ characters both avoids this error and has useful results.

How do I avoid this error and surface svn revision numbers?

10

The username may not have a space. this runs without error

\documentclass{article}
\usepackage{svninfo}

\begin{document}
\svnInfo $Id: doc.tex 8 2013-04-11 19:37:31Z UserName $ %<= Id keyword substituted by svn  

\end{document}

Since Windows user name allows spaces, you can let svnInfo allow them as well. this seems to work:

enter image description here

\documentclass{article}
\usepackage{svninfo}

\makeatletter
\def\@svnInfoCrackAndEat #1 #2 #3 #4 #5 #6 $ {\@svnEndRead
  \@svnInfoCrackString #2 #3 #4 #5 {#6} $ %
}
\makeatother

\begin{document}
\svnInfo $Id: doc.tex 8 2013-04-11 19:37:31Z User Name $ %<= Id keyword substituted by svn  

[\svnInfoOwner]

\end{document}
| improve this answer | |
  • 1
    @alx9r it may be worth asking the package maintainer to update the package with this patch to support spaces – David Carlisle Apr 11 '13 at 20:55
  • Thanks very much. That indeed works. I have sent an email linking here to the package maintainer. – alx9r Apr 11 '13 at 21:41
8

You have a space in the user name:

\svnInfo $Id: doc.tex 8 2013-04-11 19:37:31Z UserName $

should work

| improve this answer | |
  • That's it. In case it helps someone else, the user name, complete with space, was lifted by ToroiseSVN from the underlying Windows 7 account. – alx9r Apr 11 '13 at 20:31
  • 2
    @alx9r ooh it would be easy enough to modify \svnInfo to allow a space sounds like that would be useful as svn is going to keep putting the space back? – David Carlisle Apr 11 '13 at 20:39
  • @DavidCarlisle Yes that would be very useful. All of the other workarounds I've found so far are pretty messy. – alx9r Apr 11 '13 at 20:44
  • @alx9r: User~Name should work – user2478 Apr 12 '13 at 5:56
  • @Herbert It might not be obvious, but that doesn't help since all of the characters between the two $ are overwritten automatically by SVN when you commit the file. – alx9r Apr 12 '13 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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