Microtype funktioniert nicht innerhalb von varwidth

Microtype funktioniert nicht innerhalb von varwidth

Ich erstelle eine Vorlage für verschiedene Texte und muss dabei varwidth verwenden. Aber es scheint, dass Microtype in dieser Umgebung nicht funktioniert. Gibt es eine Möglichkeit, es zum Laufen zu bringen?

\documentclass{book}
\usepackage[showframe]{geometry}

\pagenumbering{gobble}

\usepackage{varwidth}

\usepackage{microtype}

\begin{document}

\hfill
\begin{minipage}{.5\textwidth}
\raggedleft
A letter, however, had lately reached me in a distant part of the country~--- a letter from him~--- which, in its wildly importunate nature, had admitted of no other than a personal reply. The MS. gave evidence of nervous agitation.
\end{minipage}

\vspace{\baselineskip}

\hfill
\begin{varwidth}{.5\textwidth}
\raggedleft
A letter, however, had lately reached me in a distant part of the country~--- a letter from him~--- which, in its wildly importunate nature, had admitted of no other than a personal reply. The MS. gave evidence of nervous agitation.
\end{varwidth}

\end{document}

Mikrotyp innerhalb von Minipage und Varwidth

Antwort1

varwidthzerlegt und rekonstruiert die vboxes zeilenweise, wobei die Randunterschneidungen verloren gehen. Abhilfe schafft hier die Verwendung von \leftmarginkernund \rightmarginkernzum Aufzeichnen und erneuten Einfügen der Randunterschneidungen. Dazu sind zwei Änderungen in erforderlich varwidth.sty:

% --- new dimens ---
\newdimen\@vwid@leftmargin
\newdimen\@vwid@rightmargin

\def\@vwid@sift{%
  \skip@\lastskip\unskip
  \dimen@\lastkern\unkern
  \count@\lastpenalty\unpenalty
  \setbox\z@\lastbox
%{\showoutput\showbox\z@}%
  \ifvoid\z@ \advance\sift@deathcycles\@ne \else
  % --- record left/right margin kerning ---
  \@vwid@leftmargin \leftmarginkern \z@  % <--
  \@vwid@rightmargin\rightmarginkern\z@  % <--
  \sift@deathcycles\z@ \fi
  \ifnum\sift@deathcycles>33
    \let\@vwid@sift\relax
    \PackageWarning{varwidth}{Failed to reprocess entire contents}%
  \fi
%\message{\the\sift@deathcycles: skip \the\skip@; kern \the\dimen@; penalty \the\count@. }%
%\ifhbox\z@\setbox99\hbox to0pt{\unhcopy\z@}\fi  % = message
  \ifnum\count@=\@vwid@preeqp \@vwid@eqmodefalse\fi
%\ifnum\count@=\@vwid@preeqp \message{End equation mode. }\fi
  \ifnum\count@=\@vwid@posteqp \@vwid@eqmodetrue\fi
%\ifnum\count@=\@vwid@posteqp\message{Begin equation mode. }\fi
%\if@vwid@eqmode {\showoutput\showbox\z@}\fi
  \ifnum\count@=\@vwid@toppen % finished
    \let\@vwid@sift\relax
  \else\ifnum\count@=\@vwid@offsets
    \@vwid@setoffsets
  \else
    \ifnum\count@=\@vwid@postw
    \else
      \@vwid@resetb % reset box \z@ or measure it
    \fi
    \@vwid@append
  \fi\fi
  \@vwid@sift}

und dann später:

\def\@vwid@resetb{%
  \setbox\z@\vbox\bgroup
    \ifvoid\z@
    \else
       \ifvbox\z@
         \box\z@
       \else % \hbox
         \@tempdima\hsize
         \advance\@tempdima-\@vwid@roff
         \advance\@tempdima-\@vwid@loff
         \advance\@tempdima-\p@
%\message{Test if \the\wd\z@ > \the\@tempdima, }%
         \ifdim\wd\z@>\@tempdima % full-width line; rebox it
%\message{An ordinary line or alignment. (\the\wd\z@ > \the\@tempdima) }%
            \hbox to\hsize
              {\kern\@vwid@loff
               % --- reinsert margin kerning ---
               \ifdim\@vwid@leftmargin=\z@\else\kern\@vwid@leftmargin\fi % <--
               \unhbox\z@
               \ifdim\@vwid@rightmargin=\z@\else\kern\@vwid@rightmargin\fi % <--
               \kern\@vwid@roff}%
         \else % an equation or direct \hbox
           \if@vwid@eqmode % re-center unnumbered equations
%\message{A centered equation hsize=\the\hsize. }%
              \hbox to\hsize
                {\hskip\@vwid@loff\@plus1fil
                 \unhbox\z@ \hskip\@vwid@roff\@plus1fil}%
           \else % plain narrow \hbox; leave it as-is
%\message{Plain narrow box}%
              \box\z@
    \fi\fi\fi\fi
  \egroup}

\def\@vwid@measure{%
  \ifvoid\z@
  \else
    % numbered equations not part of alignments can't be reset,
    % so force retention of full width.
    \ifnum\count@=\@vwid@postnump \ifdim\wd\z@<\linewidth
      \ifdim\@tempdima<\linewidth \@tempdima\linewidth \fi
    \fi\fi
    \ifhbox\z@
      \setbox\z@=\hbox
        {\kern\@vwid@loff 
         \ifdim\@vwid@leftmargin=\z@\else\kern\@vwid@leftmargin\fi % <--
         \unhbox\z@ 
         \ifdim\@vwid@rightmargin=\z@\else\kern\@vwid@rightmargin\fi % <--
         \kern\@vwid@roff}%
    \fi
    \ifdim\wd\z@>\@tempdima \@tempdima\wd\z@ \fi
  \fi}

verwandte Informationen