1 %%% figcut package: figures (and tables) in their own HTML page 2 %%%With contributions by Gilles Gregoire 3 \newif\iffigcut@show\figcut@showtrue 4 \DeclareOption{show}{\figcut@showtrue}%Repeat caption in main text, with link 5 \DeclareOption{noshow}{\figcut@showfalse}%Do not 6 \ProcessOptions* 7 %% Some pointers to original figure env. 8 \let\figcut@figure\figure 9 \let\endfigcut@figure\endfigure 10 \let\figcut@table\table 11 \let\endfigcut@table\endtable 12 %%Inside figure label names are recorded with a global \def 13 \let\figcut@label\label 14 \newcommand{\@def@figlabel}[1]{\global\def\csname #1@figlabel\endcsname{}} 15 \newcommand{\figlabel}[1] 16 {\@auxdowrite{\@print{\@def@figlabel}\{#1\}}% 17 \global\def\current@figlabel{#1}% 18 \figcut@label{#1}} 19 %%So that we can format ref to figures differently. 20 \let\figcut@ref\ref 21 \let\figcut@locref\@locref 22 \newcommand{\fig@locref}[2]{\@aelement{href="\@print{#}#1" target="_new"}{#2}} 23 \newcommand{\figref}[1] 24 {\let\@locref\fig@locref\figcut@ref{#1}\let\@locref\figcut@locref} 25 \renewcommand{\ref}[1] 26 {\@ifundefined{#1@figlabel}{\figcut@ref{#1}}{\figref{#1}}} 27 %%My custom figure 28 %change \hva@caption 29 \let\figcut@caption\hva@caption 30 \newsavebox{\figcut@caption@box} 31 \renewcommand{\hva@caption}[2] 32 {\global\def\figcut@caption@text{#2}% 33 \gsbox{\figcut@caption@box} 34 {\figcut@caption{#1}{#2}}\usebox{\figcut@caption@box}} 35 \newcommand{\figcut@show}[1] 36 {\@hr{.5\linewidth}{1pt}% 37 \begin{center}% 38 \renewcommand{\label}[1]{}\renewcommand{\aname}[2]{##2}% 39 \fig@locref{\current@figlabel} 40 {\csname#1name\endcsname~\csname the#1\endcsname}: \figcut@caption@text% 41 \end{center}% 42 \@hr{.5\linewidth}{1pt}} 43 %change figure env 44 \newsavebox{\figcut@figure@box} 45 \newenvironment{figcut@myfig}[1][] 46 {\begin{lrbox}{\figcut@figure@box}\let\label\figlabel\begin{figcut@figure}[]} 47 {\end{figcut@figure}\end{lrbox}% 48 \begin{cutflow}{\usebox{\figcut@caption@box}}\@out@par{\usebox{\figcut@figure@box}}\end{cutflow}% 49 \iffigcut@show\figcut@show{figure}\fi} 50 \let\figure\figcut@myfig 51 \let\endfigure\endfigcut@myfig 52 \let\figure*\figcut@myfig 53 \let\endfigure*\endfigcut@myfig 54 %change table env 55 \newenvironment{figcut@mytab}[1][] 56 {\begin{lrbox}{\figcut@figure@box}\let\label\figlabel\begin{figcut@table}[]} 57 {\end{figcut@table}\end{lrbox}% 58 \begin{cutflow}{\usebox{\figcut@caption@box}}\@out@par{\usebox{\figcut@figure@box}}\end{cutflow}% 59 \iffigcut@show\figcut@show{table}\fi} 60 \let\table\figcut@mytab 61 \let\endtable\endfigcut@mytab 62 \let\table*\figcut@mytab 63 \let\endtable*\endfigcut@mytab 64