Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Latex - input file in pdf comment

Posted on 2012-03-30
8
Medium Priority
?
930 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
[X]
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
  • 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 46

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
Simple Linear Regression
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

618 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