![垂直居中(自定义)边距注释相对于其所属段落](https://linux22.com/image/468164/%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD%EF%BC%88%E8%87%AA%E5%AE%9A%E4%B9%89%EF%BC%89%E8%BE%B9%E8%B7%9D%E6%B3%A8%E9%87%8A%E7%9B%B8%E5%AF%B9%E4%BA%8E%E5%85%B6%E6%89%80%E5%B1%9E%E6%AE%B5%E8%90%BD.png)
在论坛某人的帮助下,我能够创建一个自定义的边注,旋转 90 度并突出显示。
如果它以它所属的段落为中心,我会很高兴,纯粹是为了易于阅读/清楚地了解它所指的内容。
梅威瑟:
% Options for packages loaded elsewhere
%\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[a4paper, 12pt, oneside]{article}
\usepackage[a4paper, portrait, margin=0.9in,headheight=14.5pt]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{tikz}
\usepackage{lipsum}
%%%%%
% MY MARGIN NOTES %
\newlength{\minboxwidth}
\newlength{\maxboxwidth}
\newlength{\oldmaxboxwidth}
\newcommand*{\notefont}{\linespread{1}\normalsize\raggedright}
\makeatletter
\newcommand*{\mymarginnote}[1]{%
\setlength{\minboxwidth}{2\baselineskip}% minimum width of the text
\setlength{\maxboxwidth}{\textheight}% maximum width of the text
\setlength{\oldmaxboxwidth}{\maxboxwidth}%
\@tempcnta=10 % max. iterations
% Now we iterate to get a good boxwidth not extending
\@whilenum \@tempcnta > \z@\do {%
\advance\@tempcnta\m@ne
\settoheight{\@tempdima}{\parbox{\maxboxwidth}{\notefont #1}}%
\settodepth{\@tempdimb}{\parbox{\maxboxwidth}{\notefont #1}}%
\ifdim \dimexpr\@tempdima + \@tempdimb\relax <\marginparwidth
% total height of box is less than \marginparwidth -> can reduce width
\oldmaxboxwidth=\maxboxwidth
\maxboxwidth=\dimexpr (\maxboxwidth+\minboxwidth)/2\relax
\else
\ifdim \dimexpr\@tempdima + \@tempdimb\relax >\marginparwidth
% total height of box is greater than \marginparwidth -> advance width
\ifdim \maxboxwidth=\oldmaxboxwidth
% Cannot extend height -> stop and use (to small) width
\@tempcnta \z@
\else
% try to increase width
\minboxwidth=\maxboxwidth
\maxboxwidth=\oldmaxboxwidth
\fi
\else
% Don't think, that this would ever happen, but if, it would be perfect
\@tempcnta \z@
\oldmaxboxwidth=\maxboxwidth
\fi
\fi
}
%\reversemarginpar% Use left margin of oneside document
\marginpar{\hfill\rotatebox[origin=c]{270}{\parbox{\oldmaxboxwidth}{\notefont #1}}}%
}
\makeatother
%%%%%
\usepackage{xcolor}
\usepackage{soul}
\definecolor{aqua}{RGB}{0,255,255}
\newcommand{\hlc}[2][yellow]{ {\sethlcolor{#1} \hl{#2}} }
%% Creates command \colormargin that combines \mymarginnote and \hl
\makeatletter
\newcommand{\colormargin}[1]{\mymarginnote{\hlc[aqua]{#1}}}
\makeatother
%%
\makeatletter%
\long\def\@makefntext#1{%
\parindent 1em\noindent \hb@xt@ 1.8em{\hss\@makefnmark}#1%
\ifnum\the\spacefactor<3000.\fi}
\makeatother
% START DOCUMENT %
\begin{document}
\lipsum[1-4]\colormargin{margin note abc def}
\end{document}
我怎样才能使这里垂直居中\colormargin
?
谢谢!