Re: Particolare marginpar

#17927
Up
0
Down
::

Piccola correzione
`\setlength{\marginparwidth}{2cm}`
al posto di
`\setlength{\marginpar}{2cm}`

Non era l’unica magagna. Occorre tenere conto che le due righe devono andare al margine e con le macro descritte non succede. Scrivo di nuovo tutto.
`\newbox\barleftbox
\newbox\barrightbox
{\setlength\fboxsep{0pt}\setlength\fboxrule{0pt}
\global\setbox\barleftbox=\hbox{%
\colorbox[gray]{.8}{\hskip 4pt\relax\vrule height3pt width 0pt}%
\hskip4pt}
\dimen0=\ht\barleftbox \advance\dimen0-1pt
\ht\barleftbox=\dimen0
\dp\barleftbox=-1pt
\global\setbox\barrightbox=\hbox{%
\hskip4pt
\colorbox[gray]{.8}{\hskip 4pt\relax\vrule height3pt width 0pt}}
\dimen0=\ht\barrightbox \advance\dimen0-1pt
\ht\barrightbox=\dimen0
\dp\barrightbox=-1pt
}

\newcommand*{\thethmname}{}
\newtheorem{innerthm}{\thethmname}
%\newtheorem{innerthm}{\thethmname}[chapter] % se i teoremi vanno numerati per capitolo

\makeatletter
\newenvironment{thm}[1]
{\par\addvspace{\medskipamount}\noindent\renewcommand{\thethmname}{#1}%
\valign\bgroup##\cr\leaders\copy\barleftbox\vfill\cr
\vbox\bgroup\advance\hsize-8pt\vspace*{-1ex}
\begin{innerthm}}
{\end{innerthm}\vspace*{-1ex}\egroup\cr\egroup\par\addvspace{\medskipamount}}
\makeatother

\newenvironment{striscia}
{\par\addvspace{\medskipamount}\noindent%
\valign\bgroup##\cr\leaders\copy\barleftbox\vfill\cr
\vbox\bgroup\advance\hsize-8pt
}
{\egroup\cr\egroup\par\addvspace{\medskipamount}}

\setlength{\marginparwidth}{2cm} % o qualche altro valore

\newcommand{\leftstrip}[1]{%
\valign{##\cr
\leaders\copy\barleftbox\vfill\cr
\vbox{\hsize\marginparwidth\advance\hsize-8pt
\raggedright\sffamily\footnotesize #1}\cr
}
}
\newcommand{\rightstrip}[1]{%
\valign{##\cr
\vbox{\hsize\marginparwidth\advance\hsize-8pt
\raggedright\sffamily\footnotesize #1}\cr
\leaders\copy\barrightbox\vfill\cr
}
}

\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{%
\oldmarginpar[\leftstrip{#1}]{\rightstrip{#1}}}`
Ciao
Enrico

Go to top