[tex-eplain] Marginal Notes?

geolsoft at mail.ru geolsoft at mail.ru
Wed Aug 17 13:04:54 CEST 2005


On Tue, Aug 16, 2005 at 10:56:57PM -0400, Arctic Fidelity wrote:
> I couldn't find anything that was teaching me
> about these things in a simple and straightforward manner.

I think it would be difficult to teach these things in a
simple manner, it probably cannot be made any simpler than
it is in the TeXbook.  TeX is a complex system, and when you
try to do unusual things, most of the time it takes
ingenious trickery to achieve.  But the results worth it.

> I unfortunately do need to have multiple line marginal notes.

You can do this with this macro:

  \def\marginbox#1{%
    \vtop to 0pt{%
      \halign{##\hfil\cr #1\cr}%
      \vss
    }%
  }

Use it in the parameter to \doinmargin, like this:

  ...\doinmargin r{\marginbox{Text in\cr the\cr margin.}}

Or else, if you want automatic line breaking and
hyphenation, define \marginbox like this:

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

then move the line `\baselineskip=\strutdepth' in the
definition of \doinmargin right above the \null, like this:

  \def\doinmargin#1#2{\strut\vadjust{%
    \nobreak
    \kern-\strutdepth
    \vtop to \strutdepth{%
      \vss
      % if you have multiple lines of stuff to put here, you'll need to
      % make the vbox yourself of the appropriate size.
      \ifx#1l%
        \llap{\ignorespaces #2\hskip\inmarginspacing}%
      \else
        \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
      \fi
      \baselineskip=\strutdepth
      \null
    }%
  }}

Now you can use it like this:

  ...\doinmargin r{\marginbox{Text in the margin.}}

(You will need to adjust \hsize and maybe \hbadness in the
definition of \marginbox.)

If most of your marginal notes are multiline (or if you
don't mind the overhead), you can place the call to
\marginbox inside \doinmargin, so that you could avoid
repeating it in each call to \doinmargin.

-- 
Best regards,
Oleg Katsitadze



More information about the tex-eplain mailing list