[tex-eplain] Marginal notes

Adam Fenn acwfenn at hotmail.com
Thu Jun 12 13:31:18 CEST 2008


This macro for marginal notes is based upon an example by Robin Fairbairns along with some modifications from this list. It seems to work quite well although it contains a spurious space that I am unable to locate and I'm sure a number of refinements could be made to improve it.

My problem is that if I enable hyperlinks and use the indexing macros I get the following message:

pdfTeX warning (dest): name {IDXPG2} has been referenced but does not exist, replaced by a fixed one.

The warning goes away if I use the optional argument [idxexact] with \enablehyperlinks

Any suggestions how to sort this out?

Thanks,
Adam Fenn.


%------------- test file---------------

\input eplain
\enablehyperlinks%[idxexact]
\hsize = 10cm 

% \marginalia macro
\def\raggedleft{\spaceskip=.3333em \xspaceskip=.5em
     \parfillskip=0pt \leftskip=0pt plus\hsize}

\def\lmarginaliabox#1{%
    \vtop to 0pt{%
      \raggedright
      \hsize=.9in
      \parindent=0pt
      #1
      \vss
      }} 

\def\rmarginaliabox#1{%
    \vtop to 0pt{%
      \raggedleft
      \hsize=.9in
      \parindent=0pt
      #1
      \vss
     }} 

\newskip\inmarginspacing \inmarginspacing=1em
\def\strutdepth{\dp\strutbox}

\newcount\marginalno                        
\marginalno0                                

\def\marginalpage#1#2{%         
    \expandafter\def\csname marginalpage#1\endcsname{#2}}

\let\protect\relax
\newread\auxin
\newwrite\auxout
\openin\auxin\jobname.aux
\ifeof\auxin
  \let\noaux=1
  \immediate\openout\auxout\jobname.aux
  \immediate\closeout\auxout
\else
  \let\noaux=0
  \closein\auxin
\fi
\input \jobname.aux

\outer\def\bye{%
  \par\vfill\supereject
  \ifx\noaux1
    \newlinechar=`\^^J
    \message{^^J(Run TeX a second time to resolve marginal note placing)}%
  \fi
  \end
}

\immediate\openout\auxout \jobname.aux
\def\protect{\noexpand\protect\noexpand}

\def\marginalia#1{%
\strut\vadjust{%
  \nobreak
  \kern-\strutdepth
  \vtop to \strutdepth{%
    \vss

  \global\advance\marginalno1
  \edef\writeit{\write\auxout{%
                    \protect\marginalpage
                   {\number\marginalno}%
                    {\noexpand\number\count0}}}
  \writeit
  \expandafter\ifodd0\csname marginalpage\number\marginalno\endcsname
  
% odd page stuff here
\rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces
\lmarginaliabox{{\it #1}}}
\else
% even page stuff here
\llap{\ignorespaces \rmarginaliabox{{\it #1}}\hskip\inmarginspacing}
 \fi
\baselineskip=\strutdepth
\null
}}}


This is a test \marginalia{a note in the margin} to see what happens.


\vfill\eject
\idx{Test}
\vfill\eject
\readindexfile{i}
\bye
%------------------------------------

_________________________________________________________________

http://clk.atdmt.com/UKM/go/msnnkmgl0010000009ukm/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/tex-eplain/attachments/20080612/759cf110/attachment.html 


More information about the tex-eplain mailing list