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.

(Having investigated the original question, I'm taking the liberty of re-writing it as I've found a MWE and so isolated the problem, but I don't know a solution. Andrew Stacey.)

The scenario is as follows: a LaTeX document uses hyperref and, for some reason, has references as subscripts in some equation. When compiling to PDF, these are the correct size. When compiling to DVI, they come out normal size. They are still typeset in mathematics mode, just not in the right size. Here's a MWE. I'm using roman labels to better show that they are typeset in mathematics.

\documentclass{article}
\usepackage{hyperref}

\begin{document}

\begin{enumerate}
\renewcommand{\theenumi}{\roman{enumi}}
\item \label{ab} First
\item \label{cd} Second
\end{enumerate}

\[
  M_{\ref{ab}} + M_i + M_{\mathrm{i}} + N_{\ref{cd}} + N_{ii} + N_{\mathrm{ii}}
\]

\end{document}

This is from the DVI:

References with DVI

This is from the PDF:

References with PDF

This would appear to be a bug in the hdvips driver and so the obvious answer is to fix this. However, the difficulty with that is that the problem was spotted with an upload to the arXiv which, according to the logs, uses TL2009. (The document above still exhibits the fault with TL2011, by the way.) So the questions:

  1. Is there some way to fix this from within the main document?
  2. If not, and the driver needs fixing, is there a simple fix, and how could that be applied to a file uploaded to the arXiv without getting the arXiv to do anything? (For those who don't know how the arXiv works, it is possible to upload auxilliary files with the submission.)

As this is a major rewrite of the question, the original question now follows.

When I compile my LaTeX, the size of all subscripts are smaller than the normal size of text (including reference subscripts), as expected.

enter image description here

However, when the arXiv compiles my LaTeX, reference subscripts are the same size as normal text.

enter image description here

When the subscript is not also a reference, the correct font size is used.

enter image description here

I include

  • \usepackage{subfig}
  • \usepackage{graphicx}
  • \usepackage{hyperref}
  • \usepackage{tikz}
  • \usetikzlibrary{arrows,backgrounds,calc,fit}
  • \usepackage{multirow}
  • \usepackage{tyson.sty} % my personal style file

while the packages included by the arXiv LaTeX can be found in their log file from compiling my LaTeX.

Question: How can I force the arXiv to typeset reference subscripts in the correct font size?

share|improve this question
1  
Are you using hyperref when you compile the document yourself? –  Andrew Stacey Aug 17 '11 at 8:03
    
@Andrew Stacey I wasn't, but now I am. See updated question. –  Tyson Williams Aug 17 '11 at 13:33
    
@lockstep I added another example showing that the arXiv correctly renders subscripts that are not also references. Therefore, I re-added the cross-referencing tag. –  Tyson Williams Aug 17 '11 at 14:21
    
Thanks for clarifying -- looking at the original version of the question, {cross-referencing} seemed to be an inappropriate tag. –  lockstep Aug 17 '11 at 15:43
    
My next step would be to get a copy of the logfile that the arxiv produces when it compiles and see if there are any other packages that it is using that you aren't. –  Andrew Stacey Aug 17 '11 at 18:04
show 3 more comments

2 Answers

I've tracked the problem down to the file pdfmark.def which gets included by the hdvips.def driver. The reference link is typeset in a box and so if the external environment is mathematical, it needs to restore the mathematics mode inside the box. Unfortunately, as I found out in my question Is there a test for the different styles inside maths mode? there isn't a way for TeX to know absolutely which maths mode it is in.

One could include a \mathchoice macro here to sort this out, but that would be quite complicated and a smaller hack is to allow the user to specify whether or not the link is in a subscript or whatever.

This involves hacking pdfmark.def a little to add a style selection macro. Against the version in TL2010, the patch file is:

=== modified file 'pdfmark.def'
--- pdfmark.def 2011-08-18 19:15:22 +0000
+++ pdfmark.def 2011-08-18 19:15:44 +0000
@@ -223,6 +223,7 @@
     \hbox\bgroup
     \Hy@RestoreSpaceFactor
     \Hy@LinkMath
+        \Hy@mathstyle
   \fi
   \expandafter\Hy@colorlink\csname @#1color\endcsname
   \literalps@out{H.S}%
@@ -517,6 +518,13 @@
 \providecommand*{\Hy@setouterhbox}{\sbox}
 \providecommand*{\Hy@breaklinksunhbox}{\unhbox}
 \def\Hy@DEST{/DEST}
+\def\Hy@mathstyle{%
+\ifmmode
+\csname \Hy@currentmstyle\endcsname
+\fi
+}%
+\def\setmathstyle#1{\def\Hy@currentmstyle{#1style}}%
+\def\Hy@currentmstyle{textstyle}%
 \def\pdf@rect#1{%
   \begingroup
     \chardef\x=1 %
@@ -548,6 +556,7 @@
       \Hy@setouterhbox\pdf@box{%
         \Hy@RestoreSpaceFactor
         \Hy@LinkMath
+        \Hy@mathstyle
         \Hy@AllowHyphens#1\Hy@xspace@end
         \Hy@LinkMath
         \Hy@SaveSpaceFactor
@@ -556,6 +565,7 @@
       \sbox\pdf@box{%
         \Hy@RestoreSpaceFactor
         \Hy@LinkMath
+        \Hy@mathstyle
         #1\Hy@xspace@end
         \Hy@LinkMath
         \Hy@SaveSpaceFactor

We define a new command \Hy@mathstyle which is a hook to select a maths style based on a macro \Hy@currentmstyle. So if we set that macro accordingly, the hyperlink will be typeset in the corresponding style.

Then in the document itself, we define a command \subref which sets the default style to be script and then calls \ref. We check to see if the setmathstyle command is defined so that if run with pdflatex, for example, this just calls \ref.

\makeatletter
\def\subref{%
  \@ifundefined{setmathstyle}{}{\setmathstyle{script}}\ref}
\makeatother

So the total document is:

\documentclass{article}
\usepackage{hyperref}

% hdvips: hdvips.def, pdfmark.def
% hpdftex: hpdftex.def

\makeatletter
\def\subref{%
  \@ifundefined{setmathstyle}{}{\setmathstyle{script}}\ref}
\makeatother
\begin{document}

\begin{enumerate}
\renewcommand{\theenumi}{\roman{enumi}}
\item \label{ab} First
\item \label{cd} Second
\end{enumerate}

\[
  M_{\subref{ab}} + M_i + M_{\mathrm{i}} + N_{\subref{cd}} + N_{ii} + N_{\mathrm{ii}}
\]

\end{document}

with result from the DVI:

DVI with subscript references

To make this work with the arXiv, you'd have to include the modified pdfmark.def with the submission. You should probably also get the pdfmark.def file from TL2009 and modify that since the hyperref files check for the right version.

share|improve this answer
    
"Unfortunately, as I found out in my question..., there isn't a way for TeX to know absolutely which maths mode it is in." Then why doesn't this problem also happen for PDFLaTeX? –  Tyson Williams Aug 18 '11 at 20:27
    
@Tyson: In essence, the DVI version has to escape out of maths mode before it starts rendering the link. It can tell that it was in maths mode and so go back in to it, but it can't tell which maths style it was using. My guess is that the PDF version doesn't have to do this escape in the first place so can just use the ambient maths style which is guaranteed to be right. –  Andrew Stacey Aug 19 '11 at 18:04
add comment
up vote 1 down vote accepted

From arXiv help:

You can ensure pdflatex processing by setting \pdfoutput=1 within the first 5 lines of the preamble of the main pdflatex file.

There is more important information on the arXiv help page about this setting so be sure to read it.

share|improve this answer
    
Of my rewrite, you answered "1" and I answered "2"! I think that you should change the accepted answer to this one: it's probably the more useful of the two to someone looking to fix this with an upload to the arXiv. –  Andrew Stacey Aug 20 '11 at 18:08
    
@Andrew Stacey Will do. Thanks again for the tremendous effort you put into this question. –  Tyson Williams Aug 21 '11 at 3:17
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.