Debian Codegraph @

texmf-dist/doc/latex/inlinegraphicx/inlinegraphicx-doc.tex

raw
1 % !TeX TXS-program:compile = txs:///arara
2 % arara: pdflatex: {shell: no, synctex: no, interaction: batchmode}
3 % arara: pdflatex: {shell: no, synctex: no, interaction: batchmode}
4
5 \documentclass[11pt,a4paper]{ltxdoc}
6 \usepackage{bera}
7 \usepackage{inconsolata}
8 \usepackage[T1]{fontenc}
9 \usepackage[scale=0.875]{cabin}
10 \usepackage{inlinegraphicx}
11 \usepackage{fancyvrb}
12 \usepackage{fancyhdr}
13 \usepackage{tabularray}
14 \usepackage{fontawesome5}
15 \fancyhf{}
16 \renewcommand{\headrulewidth}{0pt}
17 \lfoot{\sffamily\small [inlinegraphicx]}
18 \cfoot{\sffamily\small - \thepage{} -}
19 \rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}}
20 \usepackage{hologo}
21 \providecommand\tikzlogo{Ti\textit{k}Z}
22 \providecommand\TeXLive{\TeX{}Live\xspace}
23 \let\TikZ\tikzlogo
24
25 \usepackage{hyperref}
26 \urlstyle{same}
27 \hypersetup{pdfborder=0 0 0}
28 \usepackage[margin=2cm]{geometry}
29 \setlength{\parindent}{0pt}
30 \def\TPversion{0.20a}
31 \def\TPdate{20/02/2026}
32 \usepackage{tcolorbox}
33 \usepackage{pgffor}
34 \tcbuselibrary{breakable,skins,hooks,listingsutf8}
35 %\usepackage{soul}
36 %\sethlcolor{lightgray!25}
37
38 \lstset{
39 language=[LaTeX]TeX,%
40 basicstyle=\ttfamily,%
41 keywordstyle={\color{blue}},%
42 classoffset=0,%
43 keywords={},%
44 alsoletter={-},%
45 keywordstyle={\color{blue}},%
46 classoffset=1,%
47 alsoletter={-},%
48 morekeywords={inlinegraphicx,calc,simplekv,graphicx},%
49 keywordstyle={\color{violet}},%
50 classoffset=2,%
51 alsoletter={-},%
52 morekeywords={\inlinegraphics,\includegraphics},%
53 keywordstyle={\color{green!50!black}},%
54 classoffset=3,%
55 morekeywords={scale,strut},%
56 keywordstyle={\color{orange!75!black}}
57 }
58
59 \newtcblisting{DemoCode}[1]{%
60 enhanced,width=\linewidth,%
61 bicolor,size=title,%
62 colback=cyan!10!white,%
63 colbacklower=cyan!5!white,%
64 colframe=cyan!75!black,%
65 listing options={%
66 breaklines=true,%
67 breakatwhitespace=true,%
68 style=tcblatex,basicstyle=\small\ttfamily,%
69 tabsize=4,%
70 commentstyle={\itshape\color{gray}},
71 keywordstyle={\color{blue}},%
72 classoffset=0,%
73 keywords={\usepackage,\includegraphics,xstring,listofitems,tikz,calc,simplekv,graphicx,\readlist,\showitems,\xintFor,\xintSeq,\draw,\node},%
74 alsoletter={-},%
75 keywordstyle={\color{blue}},%
76 classoffset=1,%
77 alsoletter={-},%
78 morekeywords={euromoney},%
79 keywordstyle={\color{violet}},%
80 classoffset=2,%
81 alsoletter={-},%
82 morekeywords={\inlinegraphics,\includegraphics},%
83 keywordstyle={\color{green!50!black}},%
84 classoffset=3,%
85 morekeywords={scale,strut},%
86 keywordstyle={\color{orange!75!black}}
87 },%
88 #1
89 }
90
91 \newtcbinputlisting\DemoCodeFile[1]{%
92 enhanced,width=\linewidth,%
93 bicolor,size=title,%
94 colback=lightgray!10!white,%
95 colbacklower=lightgray!5!white,%
96 colframe=lightgray!75!black,%
97 listing options={%
98 breaklines=true,%
99 breakatwhitespace=true,%
100 style=tcblatex,
101 basicstyle=\tiny\ttfamily,%
102 tabsize=4,%
103 commentstyle={\itshape\color{gray}},%
104 %lastline=148
105 },%
106 breakable,
107 listing only,%
108 listing file={#1}
109 }
110
111 \NewDocumentCommand\ShowCode{ m }{%
112 \colorbox{lightgray!50}{\lstinline!#1!}%
113 }
114
115 \begin{document}
116
117 \thispagestyle{empty}
118
119 \begin{center}
120 \begin{minipage}{0.88\linewidth}
121 \begin{tcolorbox}[colframe=yellow,colback=yellow!15]
122 \begin{center}
123 \renewcommand{\arraystretch}{1.25}%
124 \begin{tabular}{c}
125 {\Huge \texttt{inlinegraphicx}}\\
126 \\
127 {\LARGE Includegraphics, with an} \\
128 {\LARGE automatic inline positioning.} \\
129 \\
130 {\small \texttt{Version \TPversion{} -- \TPdate}}
131 \end{tabular}
132 \end{center}
133 \end{tcolorbox}
134 \end{minipage}
135 \end{center}
136
137 \begin{center}
138 \begin{tabular}{c}
139 \texttt{Cédric Pierquet}\\
140 {\ttfamily c pierquet -- at -- outlook . fr}\\
141 \texttt{\url{https://github.com/cpierquet/latex-packages/tree/main/inlinegraphicx}} \\
142 \end{tabular}
143 \end{center}
144
145 \hrule
146
147 \vfill
148
149 \begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
150 {Inline insertion, \inlinegraphics{example-image-16x10} with automatic adjustments.}
151 \end{tcolorbox}
152
153 \begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
154 \sffamily{\LARGE Inline insertion, \inlinegraphics{example-image-16x10} with automatic adjustments.}
155 \end{tcolorbox}
156
157 \begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
158 {Inline insertion, \inlinegraphics*{example-image-16x10} with automatic adjustments but without depth.}
159 \end{tcolorbox}
160
161 \begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
162 \scalebox{2.25}[2.25]{Inline \inlinegraphics[scale=0.825]{example-image-16x10} proof with small resizing.}
163 \end{tcolorbox}
164
165 \begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
166 \sffamily{\LARGE Inline insertion, (\inlinegraphics[strut={()}]{example-image-16x10}) with automatic adjustments and choice of optimal height.}
167 \end{tcolorbox}
168
169 \vfill~
170
171 \vspace*{5mm}
172
173 \pagebreak
174
175 \phantomsection
176
177 \hypertarget{matoc}{}
178
179 \tableofcontents
180
181 \vspace*{5mm}
182
183 %\hrule
184
185 \pagebreak
186
187 \section{Loading, useful packages}
188
189 In order to load \ShowCode{inlinegraphicx}, simply use:
190
191 \begin{DemoCode}{listing only}
192 \usepackage{inlinegraphicx}
193 \end{DemoCode}
194
195 The only loaded package is \ShowCode{graphicx}, the rest of the code is in \hologo{LaTeX3}.
196
197 \section{Usage}
198
199 The purpose of this package is to provide command, based on \ShowCode{\\includegraphics}, to insert graphic elements \textit{inline}, with automatic positioning and scaling.
200
201 \smallskip
202
203 The code determines (total)height and, if necessary, depth of letters in the current font, in order to position the image correctly :
204
205 \begin{itemize}
206 \item (total)height is given by (total)height of {\setlength\fboxsep{0pt}\fbox{qH}} in the current font ;
207 \item depth is given by depth of {\setlength\fboxsep{0pt}\fbox{qH}} in the current font.
208 \end{itemize}
209
210 In order to adjust manually size/positioning, \ShowCode{[keys]} are available.
211
212 \begin{DemoCode}{text only}
213 \includegraphics[scale=3]{test_inlinegraphicx}
214 \end{DemoCode}
215
216 \section{The macro}
217
218 \subsection{Arguments}
219
220 The macro for inline insertion is \ShowCode{\\inlinegraphics}.
221
222 \begin{DemoCode}{listing only}
223 \inlinegraphics(*)[scale=...,strut=...]<includegraphics options>{image}
224 \end{DemoCode}
225
226 The starred version remove depth positioning, wheres normal version include depth.
227
228 Available keys are:
229
230 \begin{itemize}
231 \item \ShowCode{scale}: re-scaling of compute height (default \ShowCode{1}) ;
232 \item \ShowCode{strut}: characters for height/depth (default \ShowCode{qH}).
233 \end{itemize}
234
235 \subsection{Examples}
236
237 \begin{DemoCode}{}
238 Inline insertion, \inlinegraphics{example-image-16x10} with automatic adjustments.
239
240 Inline insertion, \inlinegraphics[scale=0.75]{example-image-16x10} with automatic adjustments and scaling.
241
242 Inline insertion, \inlinegraphics*{example-image-16x10} with automatic adjustments and without depth.
243 \end{DemoCode}
244
245 \begin{DemoCode}{}
246 \scalebox{3}[3]{Inline (\inlinegraphics[strut={()}]{example-image-16x10}) q\inlinegraphics{example-image-16x10}H insertion}.
247 \end{DemoCode}
248
249 \begin{DemoCode}{}
250 \sffamily{\Huge Inline (\inlinegraphics[strut={()}]{example-image-16x10}) q\inlinegraphics{example-image-16x9}H insertion}.
251 \end{DemoCode}
252
253 \begin{DemoCode}{}
254 \ttfamily{\LARGE Inline (\inlinegraphics[strut={(É)}]{example-image-16x10}É) q\inlinegraphics{example-image-16x10}H insertion}.
255 \end{DemoCode}
256
257 \begin{DemoCode}{}
258 \ttfamily{\large Inline insertion, (\inlinegraphics[strut={()}]<angle=10>{example-image-16x10}) with option given to includegraphics.}
259 \end{DemoCode}
260
261 \pagebreak
262
263 \section{History}
264
265 \texttt{0.20a: Bugfix with gset (tks to D. Bitouze)}
266
267 \texttt{0.2.0: LaTeX3 version of code}
268
269 \texttt{0.1.1: Pass option to includegraphics within the macro}
270
271 \texttt{0.1.0: Initial version}
272
273 \section{The code}
274
275 \DemoCodeFile{inlinegraphicx.sty}
276
277 \end{document}