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'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?

share|improve this question
add comment

2 Answers 2

up vote 10 down vote accepted

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}
share|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
add comment

You have a space in the user name:

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

should work

share|improve this answer
    
+1 (9 sec before my deleted answer:-) –  David Carlisle Apr 11 '13 at 20:27
    
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 –  Herbert Apr 12 '13 at 5:56
show 2 more comments

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.