summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/graphicxbox/examples/grfxbox_tst_sp.tex
blob: d319013b3a314b176e4c2cb5ab14a9a2f122bfc1 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
\documentclass{article}
\usepackage{graphicxsp}
\usepackage[tight,designiv,usetemplates,nodirectory]{web}
\usepackage{graphicxbox}

\title{GraphicxBox Test File\texorpdfstring{\\}{: }Using the \textsf{GraphicxSP} 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

\embedEPS[hiresbb]{grandcanyon}{graphics/grandcanyon}
\embedEPS{indianblanket}{graphics/indianblanket}
\embedEPS{Wood-Brown}{graphics/Wood-Brown}
\embedEPS{news_bgr}{graphics/news_bgr}

\begin{document}

\maketitle

This is a demo file for the \textsf{graphicxbox} package for those who
are using the \textsf{graphicxsp} package, which requires the distiller.
This package delivers two commands, \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>,name=<name>]
        {<graphic>}{<box content>}
\end{verbatim}
The optional parameter is passed to the \cs{include\-graphics}
command,\footnote{Including addition key-value pairs defined in the
\textsf{GraphicxSP} package.} 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 not used and can be left empty.

Let's see an example.

\begin{center}
\graphicxbox[name=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
{\small\begin{verbatim}
\fgraphicxbox[<model>]{<specification>}
    [<includegraphics options>,name=<name>]{<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}[name=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[name=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[name=news_bgr]{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][\heightOf{grandcanyon}bp-2\fboxsep]
    {\widthOf{grandcanyon}bp-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{\widthOf{grandcanyon}bp} and
\texttt{\heightOf{grandcanyon}bp} are the dimensions of the photo.
Now, wrap this box in \cs{graphicxbox} using the \texttt{grandcanyon}
photo
\begin{center}
\graphicxbox[name=grandcanyon]{}{%
  \begin{minipage}[b][\heightOf{grandcanyon}bp-2\fboxsep]{\widthOf{grandcanyon}bp-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}[name=grandcanyon]{}{%
  \begin{minipage}[b][\heightOf{grandcanyon}bp-2\fboxsep-2\fboxrule]{\widthOf{grandcanyon}bp-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}
Cool! That's the \textsf{graphicxbox} package.

\textbf{\textcolor{red}{Notes:}} This file has a size of 83KB,\footnote{83KB before additional text and fonts were introduced
into this version of the document.} and \texttt{grfxbox\_tst.pdf},
as produced by \textsf{pdftex}, has file size 111KB. GraphicxSP embeds the file once, and reuses
the graphic. We got a slight savings on file space.

See the demo file \texttt{grfxbox\_tst\_indians.pdf} for an example of the use
of transparency and tiling.

\end{document}