summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ximera/src/image.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/ximera/src/image.dtx')
-rw-r--r--macros/latex/contrib/ximera/src/image.dtx60
1 files changed, 60 insertions, 0 deletions
diff --git a/macros/latex/contrib/ximera/src/image.dtx b/macros/latex/contrib/ximera/src/image.dtx
new file mode 100644
index 0000000000..e8e0a96e5a
--- /dev/null
+++ b/macros/latex/contrib/ximera/src/image.dtx
@@ -0,0 +1,60 @@
+% \subsubsection{Images}
+% \DescribeEnv{image}{Place images inside an |image| environment. On paper, this centers the image. On the web, this provides additional benefits.}
+% \begin{macrocode}
+%<*classXimera>
+%\newenvironment{image}[1][]{\begin{center}}{\end{center}}
+\NewEnviron{image}[1][3in]{%
+ \begin{center}\resizebox{#1}{!}{\BODY}\end{center}% resize and center
+}
+%</classXimera>
+% \end{macrocode}
+% \DescribeMacro{\alt}{Inside an |image| environment, |\alt| provides alt-text for assistive technology like screenreaders.}
+% \begin{macrocode}
+%<*classXimera>
+\newcommand{\alt}[1]{}
+%</classXimera>
+% \end{macrocode}
+% The |image| environment doesn't actually work in tex4ht as defined
+% with NewEnviron; so this renewenvironment is needed.
+% image-environment also gets formatted in a well, and when the user
+% clicks on the image, it zooms in.
+% \begin{macrocode}
+%<*htXimera>
+\newcounter{imagealt}
+\setcounter{imagealt}{0}
+\renewenvironment{image}[1][]{\stepcounter{imagealt}%
+ \ifvmode \IgnorePar\fi \EndP%
+ \HCode{<div class="image-environment" role="img" aria-labelledby="image-alt-\arabic{imagealt}">}%
+}{\HCode{</div>}}
+\renewcommand{\alt}[1]{\HCode{<div style="display: none;" id="image-alt-\arabic{imagealt}">}#1\HCode{</div>}}
+%</htXimera>
+% \end{macrocode}
+% Although we accept many formats, SVG is preferred on the web.
+% Since we have a different mechanism for producing |alt| text, we
+% want to ignore tex4ht's own method fo producing alt text.
+% \begin{macrocode}
+%<*cfgXimera>
+\DeclareGraphicsExtensions{.jpg,.png,.gif,.svg}
+\Configure{graphics*}
+{svg}{
+ {\Configure{Needs}{File: \Gin@base.svg}\Needs{}}
+ \Picture[]{\csname Gin@base\endcsname.svg \csname a:Gin-dim\endcsname}%
+}
+%</cfgXimera>
+% \end{macrocode}
+% This is a hack to kill |includegraphics| commands in
+% |\documentclass{standalone}| files
+% \begin{macrocode}
+%<*cfgXimera>
+\ifcsname ifstandalone\endcsname
+ \ifstandalone
+ \renewcommand\includegraphics[2][]{}
+ \fi
+%</cfgXimera>
+% \end{macrocode}
+% PGF sometimes causes trouble, but we simply don't care in tex4ht mode.
+% \begin{macrocode}
+%<*htXimera>
+\newcommand{\pgfsyspdfmark}[3]{}
+%</htXimera>
+% \end{macrocode}