| 1 |
% !TeX root = tcolorbox.tex |
| 2 |
% include file of tcolorbox.tex (manual of the LaTeX package tcolorbox) |
| 3 |
\clearpage |
| 4 |
\section{Inclusion of Boxed Image Files}\label{sec:includegraphics}% |
| 5 |
\tcbset{external/prefix=external/graphics_}% |
| 6 |
The \mylib{skins} library adds some commands to conveniently include |
| 7 |
boxed image files. |
| 8 |
For the following macros and options, the \mylib{skins} library has to be loaded |
| 9 |
by a package option or inside the preamble by: |
| 10 |
\begin{dispListing} |
| 11 |
\tcbuselibrary{skins} |
| 12 |
\end{dispListing} |
| 13 |
|
| 14 |
See \zvref{sec:skins} for the documentation of all other options of the \mylib{skins} library. |
| 15 |
|
| 16 |
\subsection{Macros} |
| 17 |
|
| 18 |
\begin{docCommand}[doc new and updated={2014-11-14}{2016-07-13}]{tcbincludegraphics}{\oarg{options}\marg{file name}} |
| 19 |
In principle, this macro includes an image file denoted by \meta{file name} |
| 20 |
using the standard |\includegraphics| and puts it into a \refEnv{tcolorbox}. |
| 21 |
The \meta{options} are |tcolorbox| keys to set up the colored box. |
| 22 |
Use \refKey{/tcb/graphics options} to specify options for the underlying |
| 23 |
|\includegraphics|. |
| 24 |
Some |tcolorbox| option keys are automatically set, namely \refKey{/tcb/enhanced} and |
| 25 |
options to center the image inside the box. |
| 26 |
|
| 27 |
The sizing of the included image is done depending on the following: |
| 28 |
\begin{itemize} |
| 29 |
\item If a \refKey{/tcb/width} is specified, but no fixed \refKey{/tcb/height}, |
| 30 |
the image is sized to fill the inner width of the box. The height of the |
| 31 |
box adapts to the image. |
| 32 |
\item If a fixed \refKey{/tcb/height} is specified, the image is sized to fill |
| 33 |
the fixed inner area of the box. |
| 34 |
\item If the \refKey{/tcb/capture} mode \refKey{/tcb/hbox} is specified, |
| 35 |
the image is sized according to given |\includegraphics| options only. |
| 36 |
The box adapts to the image. |
| 37 |
\end{itemize} |
| 38 |
|
| 39 |
\begin{dispExample} |
| 40 |
% \tcbuselibrary{raster} |
| 41 |
\begin{tcbraster}[raster columns=3,raster force size=false,size=fbox, |
| 42 |
colframe=red!50!black,colback=red!20!black, |
| 43 |
fonttitle=\bfseries,center title,drop fuzzy shadow] |
| 44 |
\tcbincludegraphics[title=Normal]{goldshade.png} |
| 45 |
\tcbincludegraphics[title=Fixed height,height=3cm]{goldshade.png} |
| 46 |
\tcbincludegraphics[title=hbox mode,hbox,graphics options={width=3cm}] |
| 47 |
{goldshade.png} |
| 48 |
\end{tcbraster} |
| 49 |
\end{dispExample} |
| 50 |
|
| 51 |
\clearpage |
| 52 |
The auxiliary macro \docAuxCommand{imagename} may be used inside |
| 53 |
\refCom{tcbincludegraphics} to display the name of the file. |
| 54 |
\docAuxCommand{imagename} is already partially detokenized and is allowed to |
| 55 |
contain special characters like the underscore. Note that an appropriate |
| 56 |
font is required to display such characters. |
| 57 |
%\docAuxCommand{imagepath}% |
| 58 |
|
| 59 |
\begin{dispExample} |
| 60 |
% \tcbuselibrary{raster} |
| 61 |
\begin{tcbraster}[size=fbox, |
| 62 |
colframe=red!50!black,colback=red!20!black, |
| 63 |
fonttitle=\bfseries\ttfamily,center title,drop fuzzy shadow] |
| 64 |
\tcbincludegraphics[title=\imagename]{goldshade.png} |
| 65 |
\tcbincludegraphics[finish={ |
| 66 |
\node[fill=white,fill opacity=0.5,text opacity=1] |
| 67 |
at (frame.center) {\bfseries\ttfamily\imagename};}]{blueshade.png} |
| 68 |
\end{tcbraster} |
| 69 |
\end{dispExample} |
| 70 |
\end{docCommand} |
| 71 |
|
| 72 |
\clearpage |
| 73 |
\begin{docCommand}[doc new=2014-11-14]{tcbincludepdf}{\oarg{options}\marg{file name}} |
| 74 |
This is a generalized version of \refCom{tcbincludegraphics} which allows |
| 75 |
to include a complete PDF file denoted by \meta{file name}. |
| 76 |
Every page is boxed into an own \refEnv{tcolorbox} customized by the |
| 77 |
given \meta{options}. It is reasonable to put such a series of boxes |
| 78 |
inside a \refEnv{tcbraster} for alignment. |
| 79 |
|
| 80 |
Use \refKey{/tcb/graphics pages} to use a selection of pages instead of |
| 81 |
using the whole file. |
| 82 |
|
| 83 |
The auxiliary macro \docAuxCommand{imagepage} may be used inside |
| 84 |
\refCom{tcbincludepdf} to display the current page number. |
| 85 |
\end{docCommand} |
| 86 |
|
| 87 |
|
| 88 |
\begin{dispListing} |
| 89 |
% \tcbuselibrary{raster} |
| 90 |
\begin{tcbraster}[raster columns=3,colframe=blue,colback=white, |
| 91 |
colbacktitle=blue!50!white,fonttitle=\small\bfseries\ttfamily, |
| 92 |
left=0pt,right=0pt,top=0pt,bottom=0pt,boxsep=0pt,boxrule=0.6pt, |
| 93 |
toptitle=1mm,bottomtitle=1mm,drop lifted shadow,center title, |
| 94 |
graphics pages={1,...,6},title={\imagename\ [\imagepage]}] |
| 95 |
\tcbincludepdf{tcolorbox-example.pdf} |
| 96 |
\end{tcbraster} |
| 97 |
\end{dispListing} |
| 98 |
{\tcbusetemp} |
| 99 |
|
| 100 |
|
| 101 |
\clearpage |
| 102 |
\subsection{Option Keys} |
| 103 |
|
| 104 |
\begin{docTcbKey}[][doc new and updated={2014-11-14}{2018-03-18}]{graphics options}{=\meta{options}}{no default, initially empty} |
| 105 |
Used for \refCom{tcbincludegraphics} and \refCom{tcbincludepdf} to |
| 106 |
specify |\includegraphics| \meta{options}. |
| 107 |
Note that \meta{options} will be fully expanded. |
| 108 |
|
| 109 |
\begin{dispExample} |
| 110 |
% \tcbuselibrary{raster} |
| 111 |
\begin{tcbraster}[raster columns=3,size=fbox,raster equal height, |
| 112 |
colframe=red!50!black,colback=red!20!black,drop fuzzy shadow] |
| 113 |
\tcbincludegraphics{goldshade.png} |
| 114 |
\newcommand{\myangle}{angle=20}% |
| 115 |
\tcbincludegraphics[graphics options=\myangle]{goldshade.png} |
| 116 |
\tcbincludegraphics[graphics options={viewport=0cm 0cm 8cm 4cm,clip}] |
| 117 |
{goldshade.png} |
| 118 |
\end{tcbraster} |
| 119 |
\end{dispExample} |
| 120 |
\end{docTcbKey} |
| 121 |
|
| 122 |
|
| 123 |
\begin{docTcbKey}[][doc new=2014-11-14]{graphics directory}{=\meta{directory}}{no default, initially empty} |
| 124 |
Used for \refCom{tcbincludegraphics} and \refCom{tcbincludepdf} to |
| 125 |
specify a file system \meta{directory} where the image files are located. |
| 126 |
\begin{dispListing} |
| 127 |
\tcbset{ |
| 128 |
graphics directory={.}, |
| 129 |
graphics directory={examples}, |
| 130 |
graphics directory={../../pictures}, |
| 131 |
} |
| 132 |
\end{dispListing} |
| 133 |
\smallskip |
| 134 |
\begin{marker} |
| 135 |
The |\graphicspath| macro from the \refPkg{graphics} package is superior to this option. |
| 136 |
\refKey{/tcb/graphics directory} may be used especially for |
| 137 |
\refCom{tcbincludepdf}. |
| 138 |
\end{marker} |
| 139 |
\end{docTcbKey} |
| 140 |
|
| 141 |
\begin{docTcbKey}[][doc new=2014-11-14]{graphics pages}{=\meta{selection}}{no default, initially |1,...,|\cs{pdfpages}} |
| 142 |
Used for \refCom{tcbincludepdf} to specify a \meta{selection} of pages to be included. |
| 143 |
The largest page number is accessible by \docAuxCommand{pdfpages}. |
| 144 |
The \meta{selection} has to be given using the |\foreach| syntax of \tikzname. |
| 145 |
\begin{dispListing} |
| 146 |
\tcbset{ |
| 147 |
graphics pages={1,3,7}, |
| 148 |
graphics pages={1,...,10}, |
| 149 |
graphics pages={1,3,...,18}, |
| 150 |
graphics pages={100,...,\pdfpages}, |
| 151 |
} |
| 152 |
\end{dispListing} |
| 153 |
\end{docTcbKey} |
| 154 |
|
| 155 |
\clearpage |
| 156 |
|
| 157 |
|
| 158 |
\begin{docTcbKey}[][doc new=2018-03-21]{graphics orientation}{=\meta{orientation}}{no default, initially |as-is|} |
| 159 |
Used for \refCom{tcbincludegraphics} and \refCom{tcbincludepdf} to |
| 160 |
guarantee a certain \meta{orientation} of the included image. |
| 161 |
After all other options for the image are processed, the result is possibly |
| 162 |
rotated to be in landscape or portrait mode. |
| 163 |
|
| 164 |
Feasible values for \meta{orientation} are: |
| 165 |
\begin{itemize} |
| 166 |
\item\docValue{as-is}: no rotation of the processed image. |
| 167 |
\item\docValue{landscape}: |
| 168 |
the processed image is possibly rotated by 90 degrees |
| 169 |
to ensure that the final width is not smaller than the final height. |
| 170 |
\item\docValue{landscape*}: |
| 171 |
the processed image is possibly rotated by -90 degrees |
| 172 |
to ensure that the final width is not smaller than the final height. |
| 173 |
\item\docValue{portrait}: |
| 174 |
the processed image is possibly rotated by 90 degrees |
| 175 |
to ensure that the final height is not smaller than the final width. |
| 176 |
\item\docValue{portrait*}: |
| 177 |
the processed image is possibly rotated by -90 degrees |
| 178 |
to ensure that the final height is not smaller than the final width. |
| 179 |
\end{itemize} |
| 180 |
|
| 181 |
\begin{dispExample} |
| 182 |
% \tcbuselibrary{raster} |
| 183 |
\begin{tcbraster}[raster columns=6,size=fbox,raster equal height, |
| 184 |
colframe=red!50!black,colback=red!20!black,drop fuzzy shadow] |
| 185 |
\tcbincludegraphics{Basilica_5.png} |
| 186 |
\tcbincludegraphics[graphics orientation=landscape]{Basilica_5.png} |
| 187 |
\tcbincludegraphics[graphics orientation=portrait]{Basilica_5.png} |
| 188 |
\tcbincludegraphics[graphics orientation=portrait*]{Basilica_5.png} |
| 189 |
\tcbincludegraphics[graphics options={viewport=0cm 0cm 2cm 3cm,clip}] |
| 190 |
{goldshade.png} |
| 191 |
\tcbincludegraphics[graphics options={viewport=0cm 0cm 2cm 3cm,clip}, |
| 192 |
graphics orientation=landscape]{goldshade.png} |
| 193 |
\end{tcbraster} |
| 194 |
\end{dispExample} |
| 195 |
|
| 196 |
|
| 197 |
\end{docTcbKey} |
| 198 |
|
| 199 |
|