From: leichter@zodiac.rutgers.edu
Newsgroups: comp.text.tex
Date: 17 Jul 92 22:05 MDT
Subject: Re: I want a boxed marginpar with an eq
Nf-ID: #R:ceNCD8=0_ek1Q0kE48@andrew.cmu.ed:-758601288:1992Jul17.140558.1@zodiac.rutger:-352004400:001:4810
Nf-From: zodiac.rutgers.edu!leichter    Jul 17 22:05:00 1992


In article <ceNCD8=0_ek1Q0kE48@andrew.cmu.edu>, cap+@cmu.edu (Chris Paris) writes:
> A paper I'm writing has the following broken paragraph in it:
> 
> This is a definition by recursion, so we want to use the {\tt
> recursion} function. Recall the definition of recursion shown at
> the right.  The {\tt recursion} function takes Turing machines for the
> two functions $f$ and $g$, and
> \marginpar{{\begin{boxedminipage}{\marginparwidth}
>     \begin{eqnarray*}
> 	h(0, \overline x) & = & f(\overline x) \\
> 	h(y+1, \overline x) & = & g(h(y, \overline x), y, \overline x)
>     \end{eqnarray*}
>     \end{boxedminipage}}}
> returns a Turing machine to compute $h$. The function $f$ corresponds
> to the base case of Equation \ref{plus base}. The function $f$ is the
> identity function, so we take it to be $U^1_1$. We could have assigned
> 
> It goes on a bit further with nothing complicated in it. On the line that  
> contains "\end{boxedminipage}," LaTeX complains that I can't use \vadjust  
> in vertical mode. The box comes out with not enough epace between the  
> bottom of the box and the text and way too much space between the top of  
> the box and the top of the text. The paragraph it's next to is split into  
> two. So how do you do this right?

I'm not sure where the problem with \vadjust is coming from; I CAN fix your
spacing problem.  The distributed versions of boxedminipage will give
incorrect spacing whenever the first thing in the minipage is something like
a displayed environment.  (Actually, boxedminipage inherits this problem from
the standard LaTeX minipage; it's just not usually noticeable there.)

BTW, why do you have an extra level of grouping around the boxedminipage
environment?  It isn't necessary.

Enclosed below is a fixed version of boxedminipage which will get rid of the
extra space at the top.  I'm not sure why you think there's too little space
at the bottom, but there is a tricky issue here:  Should bottom rule of the
box be \fboxsep below the bottom baseline or below the bottom line's
descenders?  I can find examples where each choice is clearly better.  The
code below measures from the bottom of the descenders.

Anyhow, try the modified boxedminipage; it may fix your problem.  If you
still get the error about \vadjust, the following MIGHT fix it:  Add
\leavevmode just after \end{minipage}.  (This might just as well make the
problem worse.)  If that doesn't work, see if you can come up with a SHORT
file that demonstrates the problem and mail it to me; I'd like to fix up
boxedminipage to work as well as possible.

NOTE TO ARCHIVE MAINTAINTERS:  Please to NOT archive this version of boxed-
minipage; I'm still playing with it.  When I'm happy with the result, I'll
make it available.
							-- Jerry
%	boxedminipage.sty
%
% %%%%%	TEST VERSION %%%%%
%
% adds the boxedminipage environment---just like minipage, but has a
% box round it!
%
% The thickness of the rules around the box is controlled by
% \fboxrule, and the distance between the rules and the edges of the
% inner box is governed by \fboxsep.
%
% This code is based on Lamport's minipage code.
%
% Fixed, 7 Jun 89 by Jerry Leichter
%	Leave \fboxsep worth of separation at top and bottom, not just at
%	the sides!
%
% Modified, Jul 92 by Jerry Leichter
%	Major re-work:  Discard leading space, just as if the top of the
%	minipage were the top of a real page.

\def\boxedminipage{\@ifnextchar [{\@iboxedminipage}{\@iboxedminipage[c]}}

\def\@iboxedminipage[#1]#2{\def\@boxtype{#1}\@tempdima=#2\relax
    \setbox\@tempboxa\vbox\bgroup % start of outermost vbox
	\hsize #2\kern1pt\penalty-10000		% Food for \vsplit
	\advance\hsize-2\fboxrule \advance\hsize-2\fboxsep
	\textwidth\hsize \columnwidth\hsize
	\@parboxrestore 
	\def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
	\let\@footnotetext\@mpfootnotetext
	\let\@listdepth\@mplistdepth \@mplistdepth\z@
	\@minipagerestore\@minipagetrue 
	\everypar{\global\@minipagefalse\everypar{}}}

\def\endboxedminipage{%
	\par\vskip-\lastskip
	\ifvoid\@mpfootins\else
	  \vskip\skip\@mpfootins\footnoterule\unvbox\@mpfootins
	  \par\vskip-\lastskip\fi
    \egroup					% End the vbox ==> \@tempboxa
    \begingroup \splittopskip\z@\splitmaxdepth\maxdimen
    \setbox0=\vsplit\@tempboxa to 1pt		% Discard leading junk
    \leavevmode \@pboxswfalse
    \if b\@boxtype \vbox
    \else \if t\@boxtype\vtop
	   \else \ifmmode \vcenter
		 \else \@pboxswtrue $\vcenter
		      \fi
	  \fi
    \fi{\hsize\@tempdima			% Begin vbox/vtop/vcenter
      \hrule\@height\fboxrule
      \hbox{%
	\vrule\@width\fboxrule \hskip\fboxsep
	\vbox{\vskip\fboxsep \unvbox\@tempboxa \vskip\fboxsep}%
        \hskip\fboxsep \vrule\@width\fboxrule
      }%
      \hrule\@height\fboxrule
    }\if@pboxsw $\fi				% End vbox/vtop/vcenter
    \endgroup
}

Newsgroups: comp.text.tex