我正在寻找一位由“学者”撰写的关于外星种族的虚构描述/讨论,用于角色扮演游戏,但我发现这在其他地方很有用。
我想把他的‘笔记’放在他发现的或正在写的一些文本的空白处。
我已经看到了\marginpar{margin text}
可以做什么:
但我更喜欢这种边注:
我怎样才能用 LaTex 做到这一点?
答案1
这是我的非常不令人满意尝试一下,但也许有人可以利用这一点来想出一个真实的解决方案。这需要对参数进行太多调整来控制评论文本的位置。
参考:
- 唯一好的部分来自 percusse 的回答模拟手绘线条。
进一步增强:
- 更换笔记的字体
- 更加自动地放置评论
代码:
\documentclass{article}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc,fit, decorations.pathmorphing}
\makeatletter
% https://tex.stackexchange.com/questions/39296/simulating-hand-drawn-lines
\pgfdeclaredecoration{penciline}{initial}{
\state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=1mm,]{
\pgfpathcurveto%
{% From
\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
{\pgfdecorationsegmentamplitude}
}
{% Control 1
\pgfmathrand
\pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{0pt}}
{\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
{\pgfmathresult\pgfdecorationsegmentamplitude}
}
}
{%TO
\pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{1pt}{1pt}}
}
}
\state{final}{}
}
\makeatother
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\CommentText}[3]{\tikzmark{#1}#3\tikzmark{#2}}
\NewDocumentCommand{\CommentPar}{%
O{}% #1 = draw options for the referenced word
O{}% #2 = draw options for the comment
O{}% #3 = draw options for the connecting line
m % #4 = left \tikzmark name
m % #5 = left \tikzmark name
m % #6 = comment
}{%
\begin{tikzpicture}[overlay,remember picture,decoration=penciline, thick]
\node [shape=rectangle,inner sep=0, draw=blue, ,rounded corners=2pt, fit={(#4.south) ($(#5.north)+(0,0.75ex)$)}, decorate, #1] (Source) {};
\node at ($(#4)!0.5!(#5)$) [blue, font=\itshape, rounded corners=5pt, decorate, #2] (Label) {#6};
\draw [draw=red, decorate, #3] (Label) to (Source);
\end{tikzpicture}
}
\begin{document}
Lorem ipsum dolor sit amet, \CommentText{ConsecA}{ConsecB}{consectetur} adipiscing elit. Fusce mollis ullamcorper augue. Cras ut bibendum est. Nullam mauris lectus, imperdiet eget interdum quis, vestibulum quis orci.
\CommentPar[draw=brown][draw=red, shift={(1.0cm,2.0cm)}, rotate=40, text width=2cm, align=center][out=-110, in=10, distance=0.1cm,->]{ConsecA}{ConsecB}{~~~Did you \\ mean~~ \\ consecutive??}
\begin{quote}
Ut tellus odio, rhoncus at blandit nec, tempor malesuada nunc. In id euismod odio. Ut lobortis varius pellentesque. Proin molestie \CommentText{estA}{estB}{est} dolor, eu tristique enim. Nulla facilisi. Curabitur pharetra sem eget sem volutpat sed sollicitudin mauris interdum. Nullam iaculis leo vitae tellus mattis aliquam. \CommentText{MexicanA}{MaxicanB}{Maecenas} metus odio, mollis ac posuere vitae, pulvinar ut orci. Nullam porta, dolor vel ornare gravida, leo mauris tempor metus, eu dignissim eros neque quis justo.
\end{quote}
\CommentPar[brown][color=blue, shift={(0.75cm,0.1cm)}, rotate=-50][draw=none]{estA}{estB}{Yes!!}
\CommentPar[brown][text width=3cm, color=violet, shift={(6.7cm,-1.5cm)}, rotate=-65][brown, out=225, in=-80, distance=0.7cm, ->]{MexicanA}{MaxicanB}{Seriously that is how you spell Mexican??}
Nulla massa nisl, tempus sit amet scelerisque ac, vulputate quis ligula. Sed a neque vel enim ultrices ullamcorper. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In hac habitasse platea dictumst. Quisque tincidunt pretium est, vitae ornare urna varius et.
\end{document}