在论坛某人的帮助下,我能够创建一个自定义的边注,旋转 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
?
谢谢!