![垂直旋转边注](https://linux22.com/image/467077/%E5%9E%82%E7%9B%B4%E6%97%8B%E8%BD%AC%E8%BE%B9%E6%B3%A8.png)
我想用它\marginnotes{text here}
创建垂直边距注释,因为对于我来说,边距太窄,边距线被断开,难以阅读。
我已经尝试过这里的解决方案:APA7 稿件中的边注/注释采用垂直文本方向 但对我来说,这只会导致一两个音节存在(尽管是垂直的),而其余的音节则消失或超出屏幕。
我的 MWE:
% Options for packages loaded elsewhere
%\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\DeclareUnicodeCharacter{02BE}{}
\documentclass[a4paper, 12pt, oneside]{article}
\usepackage[a4paper, portrait, margin=0.9in,headheight=14.5pt]{geometry}
\usepackage{caption}
\usepackage{titling}
\usepackage[onehalfspacing]{setspace}
\usepackage{titlesec}
\titlespacing*\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\usepackage[normalem]{ulem}
\usepackage{marginnote}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% START DOCUMENT %
\begin{document}
% START BODY %
abc text
\marginnote{expand on this?}
% \clearpage
\end{document}
谢谢 :)
答案1
如果我理解正确,你想要什么,你可以(替代约翰的回答)迭代以找到适合较长文本的良好宽度,该文本必须分成几行,例如(我删除了与问题无关的所有内容):
\documentclass[a4paper, 12pt, oneside]{article}
\usepackage[a4paper, portrait, margin=0.9in,headheight=14.5pt]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{graphicx}
\usepackage{blindtext}
\newlength{\minboxwidth}
\newlength{\maxboxwidth}
\newlength{\oldmaxboxwidth}
\newcommand*{\notefont}{\linespread{1}\footnotesize\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]{90}{\parbox{\oldmaxboxwidth}{\notefont #1}}}%
}
\makeatother
\begin{document}
abc text
\mymarginnote{expand on this?}
\blindtext
or
\mymarginnote{What about a longer text? Will the automatism to detect a proper
width work?}
\blindtext
\end{document}
与约翰的回答不同的是,注释并未强制适应旁边段落的高度,而只是尝试使用边距列的整个宽度。
您可以更改origin=c
为origin=l
或origin=r
以获得另一种垂直对齐的注释。您可以更改\minboxwidth
为定义另一种文本宽度,该文本不应分成几行。
注意:如果最大迭代次数太低,最终\parbox
可以根据需要更宽,但只有当框必须比更宽时才会足够宽\textheight
。