答案1
与\marginpar
、xcolor
和\fbox
。
\documentclass{article}
\usepackage[nopar]{lipsum}
\usepackage{xcolor}
\newcommand\makemargintip[2]{\textcolor{red}{\fbox{\color{black}#1}}%
\marginpar{\textcolor{red}{\raisebox{7pt}{%
\fbox{\parbox[t]{\marginparwidth}{\color{black}#2}}}}}}
\begin{document}
\lipsum[1]
\makemargintip{form}{this is a word} loops that move water first away...
\lipsum[2]
\makemargintip{form}{this is a word that goes on} loops that move water first away...
\lipsum[3]
\end{document}
如果您想要一个到达纸张边缘的,我只需将其更改\marginparwidth
为一些合适的值,在本例中为 1.64 英寸。
此外,如果希望文中的单词带下划线而不是方框,只需将\fbox
定义第一行中的更改\makemargintip
为\underline
。
\documentclass{article}
\usepackage[nopar]{lipsum}
\usepackage{xcolor}
\newcommand\makemargintip[2]{\textcolor{red}{\underline{\color{black}#1}}%
\marginpar{\textcolor{red}{\raisebox{7pt}{%
\fbox{\parbox[t]{1.64in}{\color{black}#2}}}}}}
\begin{document}
\lipsum[1]
\makemargintip{form}{this is a word} loops that move water first away...
\lipsum[2]
\makemargintip{form}{this is a word that goes on and on} loops that move water first away...
\lipsum[3]
\end{document}
在回答 OP 关于该方法不适用于偶数页的问题时,我可以推测问题与我的第二种方法有关,即在使用边距不对称的文档类时,每一页的不对称都会翻转。
这是一种半自动处理的方法,除非提示出现在前一页的延续段落中如果需要人工干预,则应[r]
在偶数页上提供可选参数([l]
对于奇数页):
\documentclass{book}
\usepackage[nopar]{lipsum}
\usepackage{xcolor,everypage}
\def\pagesense{o}
\AddEverypageHook{\if o\pagesense\gdef\pagesense{e}\else\gdef\pagesense{o}\fi}
\newcommand\makemargintip[3][x]{%
\textcolor{red}{\underline{\color{black}#2}}%
\ifx x#1%
\if o\pagesense\def\tmp{l}\else\def\tmp{r}\fi%
\marginpar{\makebox[\marginparwidth][\tmp]{\textcolor{red}{\raisebox{7pt}{%
\fbox{\hspace{20pt}\parbox[t]{1.64in}{\color{black}#3}\hspace{20pt}}}}}}%
\else%
\marginpar{\makebox[\marginparwidth][#1]{\textcolor{red}{\raisebox{7pt}{%
\fbox{\hspace{20pt}\parbox[t]{1.64in}{\color{black}#3}\hspace{20pt}}}}}}%
\fi%
}
\begin{document}
\lipsum[1]
\makemargintip{form}{this is a word} loops that move water first away...
\lipsum[2]
\makemargintip{form}{this is a word that goes on and on} loops that move water first away...
\lipsum[3-7]
\makemargintip[r]{form}{for carry over paragraph on a page, manual intervention
is needed, because it is actually ``set'' on the prior page} loops that move water first away...
\lipsum[8]
But after \makemargintip{that}{but not after that}, no optional argument is needed.
\end{document}
答案2
该todonotes
包使用与上一个答案中所示的相同的宏,但我相信它更容易操作。这是我的建议
\documentclass{article}
\usepackage{todonotes}
\usepackage{xcolor}
\usepackage{lipsum}
\newcommand{\tipword}[1]{\colorlet{currentcolor}{.}{\color{red}\fbox{\color{currentcolor}#1}}}
\newcommand{\tipitself}[1]{\todo[backgroundcolor=white,bordercolor=red,fancyline]{#1}}
\newcommand{\makemargintip}[2]{\tipword{#1}\tipitself{#2}}
\begin{document}
\lipsum[1-2]
Now this is where the tip word comes in, it's \makemargintip{form}{this is the tip} can be shaped with the todo package
\lipsum[3-4]
\end{document}