summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/graphicxbox/examples/grfxbox_tst.tex
blob: 27487591067757f1cd955a97f5fd6c8350dbcb7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
\documentclass{article}
\usepackage{graphicx}
\usepackage[pdftex,tight,designiv]{web}
\usepackage{graphicxbox}

\title{GraphicxBox Test File\texorpdfstring{\\}{: }Using the \textsf{Graphicx} Package}
\author{D. P. Story}
\subject{Graphic backgrounds to latex boxes}
\keywords{LaTeX, PDF, AcroTeX, graphics, backgrounds,}
\university{Acro\negthinspace\TeX.Net}
\email{dpstory@acrotex.net}
\def\webversion{\textcolor{webbrown}{www.acrotex.net}}
\revisionLabel{Prepared:}
\versionLabel{}

\newcommand{\cs}[1]{\texttt{\char`\\#1}}

\parindent0pt\parskip\medskipamount
\pagestyle{empty}

\begin{document}

\maketitle

This demo file---produced by \textsf{pdftex}---for the \textsf{graphicxbox} package for users
that are using the \textsf{graphicx} package, and not the
\textsf{graphicxsp} package, the latter requiring the distiller.\footnote{The package should work for any driver that supports the \textsf{color} package.}
This package delivers two commands, these are \cs{graphicxbox} and
\cs{fgraphicxbox}. These two are modeled after \cs{colorbox} and
\cs{fcolorbox} of the \textsf{color} package. These new commands are
similar to their colorful counterparts, but they insert a graphical background
in the box rather than a color background.

The syntax for \cs{graphicxbox} is
\begin{verbatim}
    \graphicxbox[<includegraphics options>]{<graphic>}
        {<box content>}
\end{verbatim}
The optional parameter is passed to the \cs{include\-graphics}
command, which is used. Do not use the \texttt{scale},
\texttt{width} or \texttt{height} options of \cs{include\-graphics},
the graphic is scaled to fit the box by \cs{graphicxbox}. The required
parameter \verb!{<graphic>}! is also passed to \cs{include\-graphics}.

Let's see an example.

\begin{center}
\graphicxbox{graphics/indianblanket}{%
  \begin{minipage}{.67\linewidth-2\fboxsep} %
  \footnotesize\bfseries\color{red}This is `the Indian Blanket' background
  graphic. These graphical background can be used for more interesting displays
  of content, or for an eye-catching presentation. Every time you create a
  box using \cs{graphicxbox} or \cs{fgraphicxbox}, you import the graphic once again.
  \end{minipage}}
\end{center}

\cs{fgraphicxbox} does the same as \cs{graphicxbox}, but places a colorful frame around
the box, just as \cs{fcolorbox} does. The syntax is
\begin{verbatim}
    \fgraphicxbox[<model>]{<specification>}
        [<includegraphics options>]{<graphic>}{<box content>}
\end{verbatim}
The first two (color) parameters are passed to the \cs{color} command, which takes
two parameters. The other three parameters are the same ones for \cs{graphicxbox}.

Here's an example

\begin{center}
\fgraphicxbox{red}{graphics/indianblanket}{%
  \begin{minipage}{.67\linewidth-2\fboxsep} %
  \footnotesize\bfseries\color{red}This is `the Indian Blanket' background
  graphic. These graphical background can be used for more interesting displays
  of content, or for an eye-catching presentation. Every time you create a
  box using \cs{graphicxbox} or \cs{fgraphicxbox}, you import the graphic once again.
  \end{minipage}}
\end{center}

As with \cs{colorbox} and \cs{fcolorbox}, the space around the box is equal to
\cs{fboxsep} on all sides, and the width of the rule is \cs{fboxrule}. These can
be changed as desired.

Here's a few more examples of graphical backgrounds.

\begin{center}
\graphicxbox{graphics/Wood-Brown}{%
  \begin{minipage}[b]{0.5\linewidth-2\fboxsep}
  \footnotesize\bfseries\color{webgreen}This is a wood-brown background, perhaps `webgreen'
  is not the best text color for this background, but, then again, I have no feel
  for color at all. In fact, I really wonder if I know what I'm doing at all. I'm pretty
  confused and disoriented most all the time.
  \end{minipage}}
\end{center}


\begin{center}
\graphicxbox{graphics/news_bgr}{%
  \begin{minipage}[b]{0.5\linewidth-2\fboxsep}
  \footnotesize\bfseries Here's a gradient-type background that I downloaded from
  the Internet. Once can, in theory, download any of your favorite backgrounds
  and use them as background graphics for a box.
  \end{minipage}}
\end{center}

What if you have a graphic that has an aspect ratio that cannot be changed
because it would distort the graphic? To use such a graphic requires the knowledge
of the dimensions of the graphic.

Let's try a photo for a graphic, now we must take care to preserve
the aspect ratio. We simply create the box so that its
dimensions have the same aspect ratio as that of the photo. Like so
{\small\begin{verbatim}
  \begin{minipage}[b][112.45bp-2\fboxsep]{149.665bp-2\fboxsep}
      \footnotesize\bfseries\color{white}%
      This is the mighty Grand Canyon, as seen from the south rim.
      Beautiful!
  \end{minipage}
\end{verbatim}
}Here, \texttt{149.665bp} and \texttt{112.45bp} are the dimensions of the photo.
Wrap this box in \cs{graphicxbox} using the \texttt{grandcanyon} photo and we have\dots
\begin{center}
\graphicxbox{graphics/grandcanyon}{%
  \begin{minipage}[b][112.45bp-2\fboxsep]{149.665bp-2\fboxsep}
  \footnotesize\bfseries\color{white}This is the mighty Grand Canyon, as seen from the
  south rim.  Beautiful!
  \end{minipage}}
\end{center}

Interesting. Now, let's try framing this picture.

\begin{center}
\setlength{\fboxrule}{4bp}
\fgraphicxbox{webblue}{graphics/grandcanyon}{%
  \begin{minipage}[b][112.45bp-2\fboxsep-2\fboxrule]{149.665bp-2\fboxsep-2\fboxrule}
  \footnotesize\bfseries\color{white}This is again, the mighty Grand Canyon, as seen from the
  south rim.  Beautiful!
  \end{minipage}}
\end{center}
We've also modified the lengths of \cs{fboxsep} and \cs{fboxrule}.

Cool! That's the \textsf{graphicxbox} package.
\end{document}