Make Notes from Lyx into Annotations on the PDF

Lyx Supports Notes. It would be great to have any notes in lyx show up as Annotations in a draft produced PDF.

For example:

LyX:

PDF:

The use case I have in mind is when showing this draft work to someone for to get some early feedback, they can see that I have notes there reminding my of content I still need to work on.

I would like a method to do this using Luatex, as my current work (and my work in general) won't build in any other engine.

Closely related to: How to annotate PDF files generated by pdflatex?

I guess the trick would be getting LyX to convert the Notes into appropriate latex pdf annotation commands. I guess this could be done by insterting some kind of python or perl etc script in to the build pipe line.

• There is also the PDF comments module in LyX. Go to Document > Settings > Modules and add "PDF comments". – scottkosty Oct 11 '14 at 16:22
• You might additionally be interested in the FiXme module. You can add it the same way. Note that I think it does not come with LyX until 2.2.0 is out (but you can download it). – scottkosty Oct 11 '14 at 16:25

As far as the yellow LyX notes are completely lost in the generated LaTeX source (i.e, the .tex file), your goal seem impossible without touching the LyX's guts or deal with the original .lyx file. An easier starting point could be use the black comments for this purpose.

With this approach, you only have to transform a \begin{comment} note \end{comment} of the verbatim package in a \pdfcomment{note} of the pdfcomment package.

How-to:

1) Go to Document > Configuration... > LaTex preamble

2) Paste the following lines:

% Change comments in PDF notes
\usepackage{pdfcomment}
\usepackage{environ}
\RenewEnviron{comment}{\pdfcomment{\BODY}}


3) Go to Insert > Note > Comment) and write some text.

This left a comment environment in the .tex file. Example of the ouput in LyX:

(you will see "Comment" instead of "Comentario" in a english OS, obviously...)

3) Go to File > Export > PDF(pdflatex)

4) Open the PDF open in Acrobat Reader:

LyX-generated LaTeX source:

%% LyX 2.0.5.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{verbatim}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{pdfcomment}
\usepackage{environ}
\RenewEnviron{comment}{\pdfcomment{\BODY}}

\makeatother

\usepackage{babel}
\begin{document}
Plain text %
\begin{comment}
This is a note (comment)
\end{comment}

\end{document}


Minimal working example in plain LaTeX

\documentclass{article}
\usepackage{verbatim}
\usepackage{pdfcomment}
\usepackage{environ}
\RenewEnviron{comment}{\pdfcomment{\BODY}}
\begin{document}
Plain text
\begin{comment}
This is a note (comment)
\end{comment}
\end{document}

• Actually you would not have to touch the guts of LyX. You would not even need to recompile. This kind of thing is defined in plain text files. You could just replace "Note"'s definition with the pdfcomment module's definition. See the text file lib/layouts/stdinsets.inc for Note's definition. It is only 13 lines. See Help > Customization for more information if curious. – scottkosty Oct 11 '14 at 16:33
• @scottkosty Not really curious :) I prefer plain LaTeX, among other reasons, to avoid deal with *.layout and std*.inc files. But it could useful for others if you develop your comment in a full answer. – Fran Oct 11 '14 at 19:36
• that's what I thought :). I'm short on time now, but if anyone reads this, and attempts my outlined solution but t does not work, they can post a detailed question with why it doesn't work and I will take a look at it. – scottkosty Oct 11 '14 at 19:48

In order to convert all your yellow LyX notes to something else, just type Alt-X in LyX to get a little command window, and then type/paste the following:

inset-forall Note inset-modify note Note Greyedout

That will convert all those notes to greyed out. You can then also change these to something else by redefining the lyxgreyedout environment, for instance by putting

% Change comments in PDF notes
\usepackage{pdfcomment}
\usepackage{environ}
\RenewEnviron{lyxgreyedout}{\pdfcomment{\BODY}}


into the preamble, as in (similar to) @Fran's suggestions.