# Create an annotation for table text on the page border

I have a table with 2 columns (for vocables, but also complete sentences) and for one of these 2 columns I want to add annotations on the page border. It must however be possible to associate the annotation with a specific set of words (in case of a complete sentence on my vocable sheet where I annotate only one or several words of a sentence). I thought of something like this. However this package doesn't work when you use tables, what I'm doing ): Thank you very much for any hint!

-
Out of curiosity: what package is used to produce the output in your example? =) –  Tomas Lycken Nov 23 '10 at 20:05
@tomas: todonotes. –  Caramdir Nov 23 '10 at 20:09

A very rough draft:

%&pdflatex
\documentclass{article}

\usepackage{tikz}

\newcommand\remarkomark[2]{%
\tikz[remember picture,baseline=(start-#1.base)]%
\node[draw=orange](start-#1){#2};%
}
\newcommand\remarkotext[2]{%
\marginpar{\tikz[remember picture]%
\node[fill=orange!20,rectangle,text width=\marginparwidth](end-#1){#2};}%
\tikz[remember picture,overlay]%
\draw[overlay,<-,thick,red] %
(end-#1.west)-- ++ (-0.5\marginparsep,0)
|- (start-#1.south);%
}

\newcommand\remarko[3]{%
% #1 symbolic name for node positions
% #2 marked text
% #3 explanation in border
\tikz[remember picture,baseline=(start-#1.base)]%
\node[draw=orange](start-#1){#2};%
%
\marginpar{\tikz[remember picture]%
\node[fill=orange!20,rectangle,text width=\marginparwidth](end-#1){#3};}%
\tikz[remember picture,overlay]%
\draw[overlay,<-,thick,red] %
(end-#1.west)-- ++ (-0.5\marginparsep,0)
|- (start-#1.south);%
}

\begin{document}
It's just filling anyway. It's just filling anyway. It's just filling anyway.
Lorem ipsum dolor \remarko{test}{sit}{or stand or whatever} amet.
Does it make a difference what I write here? It's just filling anyway.
It's just filling anyway. It's just filling anyway. It's just filling anyway.
Lorem ipsum dolor \remarko{test2}{sit}{or stand or whatever, hell I might
even be yodeling?} amet.
\begin{table}\centering
Does it make a difference what I write here?
Lorem ipsum dolor \remarkomark{test3}{sit} amet.
Does it make a difference what I write here?
Lorem ipsum dolor \remarkomark{test4}{sit}{or stand or whatever} amet.
Does it make a difference what I write here?
\end{table}
\remarkotext{test3}{or stand or whatever}
\remarkotext{test4}{or stand or whatever, I might even be yodeling?}
\end{document}


Still to do:

• a proper double-bent path
• twopage mode

Oh, and it'll need two pdflatex runs and of course it'll break if your explanation falls onto a different page. But there's not much you can do in that case anyway.

-
Thank you for your effort Ulrich, that looks really great! (and interesting you can do such things with such a small piece of code). It's also exactly what I am looking for - unfortunately it also doesn't work in tables, that's one not yet fulfilled requirement I have. Do you or anyone else know how one could get this working in tables? –  stefan.at.wpf Nov 24 '10 at 10:41
Another thing, but not that important: If the explanation falls on a different page, it breaks (like you already mentioned). Any chance to move the comment completely to the next page? There would be one comment missing on the page before the comment, so you could easily associate the comment "by hand". –  stefan.at.wpf Nov 24 '10 at 10:43
for the archive: 2 screenshots of ulrichs solution: imagebanana.com/view/soi6okgf/remarko1.jpg imagebanana.com/view/2ik15dti/remarko2.jpg On the later one you can see the page break problem. –  stefan.at.wpf Nov 24 '10 at 10:44
oh and how could one change the comment position to the left page border? Thank you very much and I hope I now don't have new ideas, it's now enough spam ;-) –  stefan.at.wpf Nov 24 '10 at 10:48
@stefan: I'd probably use something along the lines of KomaScript's \ifpageodd or whatsitsname and make the .west (vs. .east) conditional on that. If you want to go on the inner margin, that's the optional argument to \marginpar instead of the mandatory one, I believe. –  Ulrich Schwarz Nov 24 '10 at 13:00

I'm not exactly sure what you are looking for. I made a slap-dash example, mostly to see whether I understand what you are asking. Here's the code, and a pdf. If this is close to what you want, it would be easy to automate this with a macro.

\documentclass{article}
\usepackage{pst-all}
\begin{document}
\centerline{\bfseries My Table}\par
\begin{tabular}[t]{c|p{5cm}}
{\bfseries Vocables} & {\hfill\bfseries Explanations\hfill} \\\hline
\null\rule{0pt}{1pt} &  \\
{\red \framebox[1cm]{{\black blah}}} &
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
tortor. Suspendisse scelerisque mi non risus. \\
{\blue \framebox[1cm]{{\black blee}}} &
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
tortor. Suspendisse scelerisque mi non risus. \\
\end{tabular}

\marginpar{\red\framebox{%
\parbox{0.65in}{\black Lorem ipsum dolor sit amet, consectetur adipiscing elit.}}}

\marginpar{\blue\framebox{%
\parbox{0.65in}{\black Lorem ipsum dolor sit amet, consectetur adipiscing elit.}}}

\vspace{1cm}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
tortor. Suspendisse scelerisque mi non risus. Duis vitae ligula eget