I would like to be able to draw a box that shows up on in the PDF but does not print, just like the boxes around links that are made using the hyperref
package.
I would like to put a minipage
environment with multiple paragraphs inside the box.
Here's a solution using the pdfcomment
package that Martin mentioned.
Upsides:
Downsides:
As for the coordinates:
You can use the option line for defining the coordinates of lines in certain PDF annotations, e. g. in the form
{x1 y1 x2 y2}
. The origin is in the bottom left page corner. The given numbers will be interpreted as Postscript points (LaTeX unit: bp (big points)), as usual in PDF documents.
\documentclass[a4paper]{article}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{pdfcomment}
\begin{document}
\lipsum[1]
\pdflinecomment[type=polyline,lineend={/None},% = line with >2 "corners", no arrowhead
line={120 720 120 570 480 570 480 720 120 720},% adapt to your document
color=green,linewidth=1.5pt% adapt to your liking
]{}
\end{document}
The border is a PDF annotation and as I saw in the hyperref
code part of the hyperlink. Adding it without a link is seems to be not possible using existing LaTeX packages. The related pdfcomments
package also provides some annotations but also no border only AFAIK. It might be possible using some direct PDF code using \pdfliteral
, but you would need to know the PDF commands for this.
However you can add the border by placing it in a \hyperref
or \href
, but both do not allow paragraphs as content and generate a very tight border. You could use the v0.5 or higher of the adjustbox
package (relative new) to box the minipage
first which avoids the paragraph issue, add a margin if wanted and feed it to a \hyperref
which e.g. simply points to the current page. The border color can be configured as described in the hyperref
manual.
\documentclass{article}
\usepackage{hyperref}
\usepackage{adjustbox}
\newenvironment{hborderbox}[1]{%
\begin{adjustbox}{minipage=#1,margin=1ex,precode=\hyperlink{page:\the\numexpr\arabic{page}-1\relax}}%
}{%
\end{adjustbox}%
}
\usepackage{lipsum}
\begin{document}
\begin{hborderbox}{.5\textwidth}
\lipsum[1]\par\lipsum[2]
\end{hborderbox}
\end{document}
it needs \endgraf
instead of \par
\documentclass{article}
\usepackage[english]{babel}
\usepackage{hyperref}
\usepackage{blindtext}
\newcommand\TBox[1]{\href{http://tug.org}{%
\tabular{c}\begin{minipage}{0.75\linewidth}\rule{0pt}{3ex}%
#1\rule[-1ex]{0pt}{0ex}\end{minipage}\endtabular}}
\begin{document}
\TBox{\blindtext \endgraf\blindtext}
\end{document}
Paragraph ended before \href@split was complete
Commented
Aug 29, 2011 at 20:48