[XeTeX] adding a carriage return character to a PDF annotation
Ross Moore
ross at ics.mq.edu.au
Mon Dec 28 22:15:07 CET 2009
Hello Pablo,
On 29/12/2009, at 6:41 AM, Pablo Rodríguez wrote:
> Hi there,
>
> I have the following document:
>
> \documentclass{article}
> \usepackage[english]{babel}
> \begin{document}
> This is me.\special{pdf:ann << /Type /Annot /Subtype /Text /Open true
> /Contents (First line. Second line.) >>}
> \end{document}
>
> And I would like to add a new line between the first and second
> line in
> the annotation text.
> (Copying and pasting the character doesn't change anything. Either
> ^^00^^0D, ^^00^^0d, \u0d or \u0x0D work. It seems that the character
> should be written in utf-8 directly [but experts in this list should
> know more and much better than myself].)
You can use Octal codes \xxx for this.
The difficulty is getting that initial backslash character '\'
because of its special meaning in TeX.
Here is one way to do it:
>>> \documentclass{article}
>>> \usepackage[english]{babel}
>>>
>>> {\catcode`\| 0 \catcode`\\ 11
>>> |gdef |realbackslash{\}
>>> }
>>> \def\octalcr{\realbackslash 015}
>>>
>>> \begin{document}
>>> This is me.\special{pdf:ann << /Type /Annot /Subtype /Text /Open
>>> true
>>> /Contents (First line. \octalcr Second line.) >>}
>>> \end{document}
However, if you load the {hyperref} package, there are
better ways to solve this kind of problem, and many many more.
>>> \documentclass{article}
>>> \usepackage[english]{babel}
>>> \usepackage{hyperref}
>>> \pdfstringdef{\myannot}{First line.\015 Second line.}
>>>
>>> \begin{document}
>>> This is me.\special{pdf:ann << /Type /Annot /Subtype /Text /Open
>>> true
>>> /Contents (\myannot) >>}
>>>
>>> \end{document}
The \pdfstringdef copes with all of TeX's special character uses,
apart from '{' , '}' and '\' which need to be given in octal.
For this the macro \0 creates the correct '\' followed by '0' ,
so is the easiest way to provide the octal representation of
any ascii character.
>
> Thanks for your help,
>
>
> Pablo
Hope this helps,
Ross
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 (0)2 9850 8955
Sydney, Australia 2109 fax: +61 (0)2 9850 8114
------------------------------------------------------------------------
More information about the XeTeX
mailing list