Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Latex - input file in pdf comment

Posted on 2012-03-30
8
893 Views
Last Modified: 2012-06-27
Hello,

In Latex, I'm trying to include a file into a PDF comment.
I'm using the \input and \pdfmarginpar commands for that, but I don't get the expected results. Here is my code:
\pdfmarginpar{\input{test}}

Open in new window


The file "test.tex" contains only a few lines of text, without latex commands.
I would like to have the content of test.tex in the generated PDF annotation, but the \input command is not interpreted, so the content of the annotation is textually "\input{test}".
In fact, \pdfmarginpar doesn't interpret any command (I tried with \pdfmarginpar{\texbf{mytext}} that displays "\texbf{mytext}" in the annotation). I understand that we don't need formatting in annotations but not every command is for formatting purposes.

I've tried with some \expandafter, by defining a temporary command to hold the content of the file, but it still doesn't want to interpret the commands within \pdfmarginpar.

\renewcommand{tmpcmd}{\input{test}}
\pdfmarginpar{\tmpcmd}

Open in new window


Also, passing through a command parameter doesn't work:
\newcommand{\putannot}[1]{\pdfmarginpar{#1}}
\putannot{\input{test}}

Open in new window


I've tried to use \marginpar insted of \pdfmarginpar and the content of test.tex is correctly displayed in the margin of my document.


Would someone have an idea on how to extract the content of the \input command in order to pass this result to \pdfmarginpar? How can we interpret a command, store the value and pass it to \pdfmarginpar. Or how can we tell to latex to execute the inner command before the outer one? Or maybe there is another way to make them work together...

It's disappointing because it's like saying to a kid: - "Say goodbye without yelling" - "GOODBYE WITHOUT YELLIIING"

Thank you in advance,
Kind regards,

Alexandre Péclat
0
Comment
Question by:peclat
  • 4
8 Comments
 

Author Comment

by:peclat
ID: 37800180
Hi,

The test.tex file just contains some text (3 lines), there are no commands inside.
But the problem is that  \pdfmarginpar doesn't interpret any command.
Take this simple example:
\newcommand{\myname}{alex}
\pdfmarginpar{\myname}

Open in new window

will produce an annotation with "myname" instead of "alex" written.


However, I came with a solution: using pdfcomment package with command \pdfcomment{\myname} produces the expected result: "alex".
BUT it doesn't work with \include. That's not funny if it's too easy...
Now I have this code:
\pdfcomment{\input{test}}

Open in new window

That produces an annotation with "test" written inside. So this \pdfcomment command interprets \myname, but not \input{}. Maybe putting the result of \input in a temporary command, or using some expandafters (I don't really understand how they work though) will do the trick.

If you have any suggestion, they are welcome. I'll post the solution if I find it.

Thanks for your time.
Kind regards,

Alexandre Péclat
0
 

Author Comment

by:peclat
ID: 37800602
Hello,

Yes I'm editing a PDF file and I want to integrate PDF annotations (standards from Acrobat) in it. I have the Miktex 2.9 distribution and I use TeXnicCenter 1.0 as editing tool.

Kind regards,
Alexandre Péclat
0
 
LVL 45

Expert Comment

by:aikimark
ID: 37800669
you can upload your PDF file to pdfescape.com and add your annotations
http://www.pdfescape.com/

Inkscape also allows you to annotate your files.  This tool runs on your PC and is a slick image editor (in general).

There are also third-party tools that will allow you to edit PDFs, most of them cheaper than Adobe Acrobat.
0
 

Accepted Solution

by:
peclat earned 0 total points
ID: 37800881
Hello,

Thank you for the tools listing, but I was trying to automatically add content from external .tex files as annotations to the PDF I'm generating with LaTeX.

I used "was" because I finally found a solution: Instead of using \input{myfile} that is not expanded within the \pdfcomment or \pdfmarginpar commands, I now use \CatchFileDef{\mytext}{myfile} from the "catchfile" package that expands the content of the file into the \mytext argument. Note that it only works with \pdfcomment.

A little "trick", you can't use \CatchFileDef directly followed by \pdfcomment. That will make the \pdfcomment command inactive (I like little latex delights like that :-).
The issue can be resolved by using a command between them, or simply by adding 2 backslashes after the \CatchFileDef command.

So, to summarize:
\usepackage{catchfile}
\usepackage{pdfcomment}

\CatchFileDef{\sometext}{myfile.tex}\\
\pdfcomment{\sometext}

Open in new window


And here you have a pdf annotation with the content of the external file. Fairly simple isn't it?

Thank you anyway for your time.

Kind regards,
Alexandre Péclat
0
 

Author Closing Comment

by:peclat
ID: 37820831
I accepted my own solution because no other solution within the purpose was provided. I finally found the solution and posted it in order to help people with the same problem.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question