Skip to content

Commit

Permalink
Added \provideadjustboxenv and \declareadjustboxenv.
Browse files Browse the repository at this point in the history
Added \provideadjustboxcmd and \declareadjustboxcmd.
Added \declareadjustimage.
  • Loading branch information
MartinScharrer committed Jan 1, 2019
1 parent 84fb5ee commit 22ad2bd
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 20 deletions.
8 changes: 8 additions & 0 deletions adjustbox.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@
% yet.
%
%
% \DescribeMacro\declareadjustboxenv{<name>}[<num>][<default>]{<key=value,\ldots>}
% \DescribeMacro\declareadjustboxenv*{<name>}[<num>][<default>]{<key=value,\ldots>}
% Like \Macro\newadjustboxenv and \Macro\newadjustboxenv* but will always define a macro/environment even if it does already exist.
%
%
% \DescribeMacro\newadjustboxcmd{<\textbackslash macro>}[<num>][<default>]{<key=value,\ldots>}
% This declaration defines a macro which applies the given \pkg{adjustbox} keys to its content.
% As with \Macro\adjustbox the content is read as box, not as macro argument.
Expand Down Expand Up @@ -484,6 +489,9 @@
% \end{examplecode}
% \end{example}
%
% \DescribeMacro\declareadjustimage{<\textbackslash macro>}[<num>][<default>]{<key=value,\ldots>}
% Like \Macro\newadjustimage but will not cause an error if the macro is already defined.
%
%
% \DescribeMacro\NewAdjustImage{<\textbackslash macro>}{<xparse argument specification>}{<key=value,\ldots>}
% \DescribeMacro\RenewAdjustImage{<\textbackslash macro>}{<xparse argument specification>}{<key=value,\ldots>}
Expand Down
98 changes: 78 additions & 20 deletions adjustbox.sty
Original file line number Diff line number Diff line change
Expand Up @@ -477,35 +477,75 @@
% \end{macro}
%
%
% \begin{macro}{\newadjustboxcmd}
% \begin{macro}{\renewadjustboxenv}
% \begin{macrocode}
\newcommand*\newadjustboxcmd{%
\newcommand*\renewadjustboxenv{%
\begingroup
\let\@@@newadjustboxenv\@@@newadjustboxcmd
\def\new@adjustbox{\newcommand}%
\newadjustboxenv@
\@ifstar{%
\let\@@@newadjustboxenv\@@@newadjustboxenv@
\def\new@adjustbox{\renewenvironment}%
\newadjustboxenv@
}{%
\def\new@adjustbox{\renewcommand}%
\newadjustboxenv@
}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\newadjustboxenv}
% \begin{macro}{\provideadjustboxenv}
% \begin{macrocode}
\newcommand*\renewadjustboxenv{%
\newcommand*\provideadjustboxenv{%
\begingroup
\@ifstar{%
\let\@@@newadjustboxenv\@@@newadjustboxenv@
\def\new@adjustbox{\renewenvironment}%
\def\new@adjustbox{\@star@or@long\adjustbox@provideenvironment}%
\newadjustboxenv@
}{%
\def\new@adjustbox{\renewcommand}%
\def\new@adjustbox{\providecommand}%
\newadjustboxenv@
}%
}
% \end{macrocode}
% \end{macro}%
%
%
% \begin{macro}{\declareadjustboxenv}
% \begin{macrocode}
\newcommand*\declareadjustboxenv{%
\begingroup
\@ifstar{%
\let\@@@newadjustboxenv\@@@newadjustboxenv@
\def\new@adjustbox##1{%
\expandafter\let\csname ##1\endcsname\@undefined
\newenvironment{##1}%
}%
\newadjustboxenv@
}{%
\def\new@adjustbox##1{%
\let##1\@undefined
\newcommand{##1}%
}%
\newadjustboxenv@
}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\newadjustboxcmd}
% \begin{macrocode}
\newcommand*\newadjustboxcmd{%
\begingroup
\let\@@@newadjustboxenv\@@@newadjustboxcmd
\def\new@adjustbox{\newcommand}%
\newadjustboxenv@
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\renewadjustboxcmd}
% \begin{macrocode}
\newcommand*\renewadjustboxcmd{%
Expand All @@ -518,21 +558,28 @@
% \end{macro}
%
%
% \begin{macro}{\newadjustboxenv}
% \begin{macro}{\provideadjustboxcmd}
% \begin{macrocode}
\newcommand*\provideadjustboxenv{%
\newcommand*\provideadjustboxcmd{%
\begingroup
\@ifstar{%
\let\@@@newadjustboxenv\@@@newadjustboxenv@
\def\new@adjustbox{\@star@or@long\adjustbox@provideenvironment}%
\newadjustboxenv@
}{%
\def\new@adjustbox{\providecommand}%
\newadjustboxenv@
}%
\let\@@@newadjustboxenv\@@@newadjustboxcmd
\def\new@adjustbox{\providecommand}%
\newadjustboxenv@
}
% \end{macrocode}
% \end{macro}
% \end{macro}%
%
%
% \begin{macro}{\provideadjustboxcmd}
% \begin{macrocode}
\newcommand*\declareadjustboxcmd{%
\begingroup
\let\@@@newadjustboxenv\@@@newadjustboxcmd
\def\new@adjustbox##1{\let##1\@undefined\newcommand{##1}}%
\newadjustboxenv@
}
% \end{macrocode}
% \end{macro}%
%
%
% \begin{macro}{\adjustbox@provideenvironment}[1]{<environment name>}
Expand Down Expand Up @@ -678,6 +725,17 @@
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\declareadjustimage}
% \begin{macrocode}
\newcommand*\declareadjustimage{%
\begingroup
\let\@@@newadjustboxenv\@@@newadjustimage
\def\new@adjustbox##1{\let##1\@undefined\newcommand{##1}}%
\newadjustboxenv@
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@@newadjustimage}[3]{<macro name>}{<optional arguments in brackets>}{<keys>}
% \begin{macrocode}
\def\@@@newadjustimage#1#2#3{%
Expand Down

0 comments on commit 22ad2bd

Please sign in to comment.