6

I discovered some weird behaviour with xwatermark and \refstepcounter which I cannot explain. I created a list and the indentation of the first item is correct, but all others are too much indented. If instead \stepcounter is used, it's working again. Also if the xwatermark package is not loaded. The question is not how to fix this, but why this happens. The package xwatermark is not supposed to influence the layout in any way. And the connection to \refstepcounter is completely incomprehensible to me.

\documentclass{article}
\setlength{\parindent}{0pt}
\newcounter{num}
\newcommand{\ta}{\refstepcounter{num} \makebox[10mm][l]{\Roman{num})}test\\
  \hspace*{185,5mm}
  \begin{minipage}{15mm}
  \end{minipage}
}
\usepackage{xwatermark}
\begin{document}
  Test

  \ta
  \ta
  \ta
\end{document}

only first item aligned correctly with xwatermark loaded or refstepcounter used instead

     *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
xwatermark.sty    2012/10/23 v1.5.2d A dynamic watermarking scheme (Ahmed Musa)

catoptions.sty    2012/11/22 v0.2.7f Securing catcodes and parsing options (AM)

  fix-cm.sty    2006/09/13 v1.1m fixes to LaTeX
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
 picture.sty    2009/10/11 v1.3 Dimens for picture macros (HO)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
atbegshi.sty    2011/10/05 v1.16 At begin shipout hook (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
fancyhdr.sty    
atveryend.sty    2011/06/30 v1.8 Hooks at the very end of document (HO)
 ltxkeys.sty    2012/11/17 v0.0.3c A robust key-value parser (AM) (Ahmed Musa)
  framed.sty    2011/10/22 v 0.96: framed or shaded text with page breaks
    Test.xwm
hyperref.sty    2012/11/06 v6.83m Hypertext links for LaTeX
hobsub-hyperref.sty    2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2012/05/28 v1.13 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2012/05/28 v1.13 Construct package bundles (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
  ifvtex.sty    2010/03/01 v1.5 Detect VTeX and its facilities (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable calculations with integers (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
pdfescape.sty    2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
bigintcalc.sty    2012/04/08 v1.3 Expandable calculations on big integers (HO)
  bitset.sty    2011/01/30 v1.1 Handle bit-vector datatype (HO)
uniquecounter.sty    2011/01/30 v1.2 Provide unlimited unique counter (HO)
letltxmacro.sty    2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
 hopatch.sty    2012/05/28 v1.2 Wrapper for package hooks (HO)
xcolor-patch.sty    2011/01/30 xcolor patch
refcount.sty    2011/10/16 v3.4 Data extraction from label references (HO)
 hycolor.sty    2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
 auxhook.sty    2011/03/04 v1.3 Hooks for auxiliary files (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
  pd1enc.def    2012/11/06 v6.83m Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
 hpdftex.def    2012/11/06 v6.83m Hyperref driver for pdfTeX
rerunfilecheck.sty    2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
supp-pdf.mkii
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
 nameref.sty    2012/10/27 v2.43 Cross-referencing by name of section
gettitlestring.sty    2010/12/03 v1.4 Cleanup title references (HO)
10
  • Your code was missing the totcount package; I added it. I hope it's OK. Jan 24, 2014 at 23:07
  • 1
    No such weird indentation to declare, here. Have you trie updating your TeX distribution?
    – jub0bs
    Jan 24, 2014 at 23:10
  • 1
    I get no strange output. Can you add what you get by adding \listfiles at the top of the example? You'll find the file listing in the log file.
    – egreg
    Jan 24, 2014 at 23:10
  • I can confirm Jubobs' and egreg's result; no problem with indentation here. Jan 24, 2014 at 23:10
  • 1
    Remove the space before \makebox
    – egreg
    Jan 24, 2014 at 23:51

1 Answer 1

6

The problem is subtle. With xwatermark, also hyperref is loaded (I don't know why, actually). Since hyperref redefines \refstepcounter, the space after it becomes significant and it's not removed at the line break, because it comes after a node inserted by hyperref for the anchor relative to the stepped counter.

Solution: remove the offending space.

\newcommand{\ta}{\refstepcounter{num}\makebox[10mm][l]{\Roman{num})}test\\
  \hspace*{185,5mm}
  \begin{minipage}{15mm}
  \end{minipage}
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .