文本注释“云”的实现

文本注释“云”的实现

很难用一句话描述我想要什么,最好看看我通常如何记(讲座)笔记。

在此处输入图片描述

我想让你们注意这些小“云”,它们包含一些关于句子的有用但不是必要的信息。

这些笔记对我来说很重要文本而不是“外部”(作为脚注等)。

还请注意,只要有足够空间,就可以放置笔记。

我们在 TEX.SX 上已经有此类云的例子: 云示例

因此,我搜索类似\stackrel\overbrace命令的东西,以便为我完成所有对齐和间距操作(否则,手动与所有这些云对齐显然需要很长时间)。

答案1

笔记:补充twoside版本末尾添加。

除非你想把所有时间都花在手动放置文本以环绕云朵上,否则我建议将其与\marginpar机制结合起来。我对布局所做的唯一更改是减小了以便\textwidth为云朵留出空间。

\documentclass{article}
\textwidth=\dimexpr\textwidth-1in\relax
\usepackage{tikz,tabto,lipsum}
\usetikzlibrary{shapes}

\newcommand\margincloud[1]{{%
  \tabto{\textwidth}%
  \llap{%
    \rule[-\dp\strutbox]{.5pt}{\dp\strutbox}%
    \rule[-\dp\strutbox]{\dimexpr\textwidth-\TabPrevPos\relax}{.5pt}%
    \kern-3pt
    \smash{\rlap{\rotatebox[origin=lb]{45}{\rule[-\dp\strutbox]{60pt}{.5pt}}}}}%
  \tabto*{\TabPrevPos}%
  \marginpar{%
    \smash{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}%
}}

\begin{document}
This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]
 \end{document}

在此处输入图片描述

根据 OP 的要求,带有点状连接器的版本:

\documentclass{article}
\textwidth=\dimexpr\textwidth-1in\relax
\usepackage{tikz,tabto,lipsum}
\usetikzlibrary{shapes}
\def\dotfill#1{\cleaders\hbox to #1{\scalebox{1.4}{.}}\hfill}
\newcommand\dotline[2][.5em]{\leavevmode\hbox to #2{\dotfill{#1}\hfil}}
\newcommand\margincloud[1]{{%
  \tabto{\textwidth}%
  \llap{\raisebox{-\dp\strutbox}{%
    \dotline{\dimexpr\textwidth-\TabPrevPos\relax}%
    \kern-3pt
    \smash{\rlap{\rotatebox[origin=lb]{45}{\dotline[.7em]{60pt}}}}}}%
  \tabto*{\TabPrevPos}%
  \marginpar{%
    \smash{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}%
}}
\sloppy
\begin{document}
This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]
 \end{document}

在此处输入图片描述

更好的是,有一个气泡的版本:

\documentclass{article}
\textwidth=\dimexpr\textwidth-1in\relax
\usepackage{tikz,tabto,lipsum}
\usetikzlibrary{shapes}
\def\dotfill#1#2{\cleaders\hbox to #1{\scalebox{#2}{$\circ$}}\hfill}
\newcommand\dotline[3][.6em]{\leavevmode\hbox to #2{\dotfill{#1}{#3}\hfil}}
\newcommand\margincloud[1]{{%
  \tabto{\textwidth}%
  \llap{\raisebox{-\dp\strutbox}{%
    \dotline{\dimexpr\textwidth-\TabPrevPos\relax}{.6}%
    \kern-3pt
    \smash{\rlap{\rotatebox[origin=lb]{45}{\dotline[.8em]{60pt}{1}}}}}}%
  \tabto*{\TabPrevPos}%
  \marginpar{%
    \smash{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}%
}}
\sloppy
\begin{document}
This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]
 \end{document}

在此处输入图片描述

补充双面版本(使用线条,根据 OP 要求)

\documentclass[twoside]{book}
%\usepackage[left=2.5in,right=2.5in]{geometry}
\usepackage{tikz,tabto,lipsum}
\usetikzlibrary{shapes}
\def\dotfill#1#2{\xleaders\hbox to #1{\scalebox{#2}{$\circ$}}\hfill}
\newcommand\dotline[3][.6em]{\leavevmode\hbox to #2{\dotfill{#1}{#3}\hfil}}
\newcommand\margincloud{\ifodd\thepage\relax\expandafter\rmargincloud
  \else\expandafter\lmargincloud\fi}
\newcommand\lmargincloud[1]{{%
  \tabto*{0pt}%
  \smash{\rlap{%
    \smash{\llap{\rotatebox[origin=rb]{-45}{\rule[-\dp\strutbox]{60pt}{.5pt}}}}%
    \kern-2.5pt
    \rule[-\dp\strutbox]{\TabPrevPos}{.5pt}%
        \rule[-\dp\strutbox]{.5pt}{\dp\strutbox}}}%
  \tabto{\TabPrevPos}%
  \marginpar{%
    \smash{\makebox[\marginparwidth][r]{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}}%
}}
\newcommand\rmargincloud[1]{{%
  \tabto{\textwidth}%
  \smash{\llap{%
    \rule[-\dp\strutbox]{.5pt}{\dp\strutbox}%
    \rule[-\dp\strutbox]{\dimexpr\textwidth-\TabPrevPos\relax}{.5pt}%
    \kern-2.5pt
    \smash{\rlap{\rotatebox[origin=lb]{45}{\rule[-\dp\strutbox]{60pt}{.5pt}}}}}}%
  \tabto*{\TabPrevPos}%
  \marginpar{%
    \smash{\makebox[\marginparwidth][l]{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}}%
}}
\sloppy
\begin{document}

This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]

\clearpage
This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]
 \end{document}

在此处输入图片描述

答案2

有了和tikztikzmark你就可以做这样的事情。

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark,shapes.symbols,decorations.markings}
\tikzset{thought dots/.style={decoration={markings,
      mark=between positions 4pt and 0.95 step 9pt
      with
      {
        \draw (0,0) circle[radius=2pt];
      }
},decorate}}
\begin{document}
Standard philosophy $\displaystyle (M,\sigma_M)
\xrightarrow[\tikzmarknode{n}{\mathrm{nervously}}]{\mathrm{study}}(M,\sigma_M)$
\begin{tikzpicture}[overlay,remember picture]
\path[thought dots] (n) -- ++(0.5,-1) node[below,cloud,draw,align=center,aspect=2,inner sep=0pt]{study structure\\
of sets by studying\\ maps between them};
\end{tikzpicture}
\end{document}

在此处输入图片描述

您可以使用shapepar或wrapfig或类似的东西来解决对齐问题。只有在您向我们提供MWE后,我们才能判断哪个选项最适合您,从中我们可以知道您正在使用哪些软件包等等。以下内容为您提供了一个想法。

\documentclass{article}
\usepackage{amsmath}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{tikzmark,shapes.symbols,decorations.markings}
\tikzset{thought dots/.style={decoration={markings,
      mark=between positions 4pt and 0.95 step 9pt
      with
      {
        \draw (0,0) circle[radius=2pt];
      }
},decorate},iCloud/.style={cloud,draw,align=center,aspect=2,inner sep=0pt}}
\begin{document}
\setcounter{section}{3}
\section{Measurable maps}
Standard philosophy $\displaystyle (M,\sigma_M)
\xrightarrow[\tikzmarknode{n}{\mathrm{nervously}}]{\mathrm{study}}(M,\sigma_M)$

\begin{wrapfigure}[10]{r}[10pt]{6cm}
\tikzmarknode[iCloud]{nn}{study structure\\
of sets by studying\\ maps between them}
\begin{tikzpicture}[overlay,remember picture]
\path[thought dots] (n) -- (nn);
\end{tikzpicture}
\end{wrapfigure}
$\triangleright$ measurable maps

a map $f:M\to N$ is called measurable if \dots \lipsum[1]

\end{document}

在此处输入图片描述

如果您希望它们位于边缘,那么我会使用tikzpagenodes

\documentclass{article}
\usepackage[left=1in,top=1.5in,bottom=1.5in,right=2in]{geometry}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{tikzmark,shapes.symbols,decorations.markings}
\tikzset{thought dots/.style={decoration={markings,
      mark=between positions 4pt and 1-4pt step 9pt
      with
      {
        \draw (0,0) circle[radius=2pt];
      }
},decorate},iCloud/.style={cloud,draw,align=center,aspect=2,inner sep=0pt}}
\newcounter{clouds}
\newcommand{\AddThought}[3][]{\begin{tikzpicture}[overlay,remember picture]
\stepcounter{clouds}
\node[iCloud,anchor=west,#1] (cloud-\number\value{clouds}) at 
(#2.south-|current page text area.east)
{#3};
\path[thought dots] (#2) -- (cloud-\number\value{clouds});
\end{tikzpicture}}
\begin{document}
\setcounter{section}{3}
\section{Measurable maps}
Standard philosophy $\displaystyle (M,\sigma_M)
\xrightarrow[\tikzmarknode{n}{\mathrm{nervously}}]{\mathrm{study}}(M,\sigma_M)$
\AddThought{n}{study structure\\
of sets by studying\\ maps between them}

$\triangleright$ measurable maps

a map $f:M\to N$ is called measurable if \dots \lipsum[1]

Something about \tikzmarknode{d}{ducks}
\AddThought[yshift=-1cm]{d}{Why always\\
ducks? Don't we\\ have enough\\ ducks?}

\end{document}

在此处输入图片描述

相关内容