diff options
author | Karl Berry <karl@freefriends.org> | 2011-11-04 23:25:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-11-04 23:25:04 +0000 |
commit | 1267e56426be0702177637c1eadae17ffc9468f4 (patch) | |
tree | b123ac9b4b28ca2200ffaf115136ac25fcd7efb7 /Master/texmf-dist | |
parent | 68e1c235b3d6d27c0b49e8a5204ad71ad1b6ed80 (diff) |
new latex package easyfig (1nov11)
git-svn-id: svn://tug.org/texlive/trunk@24501 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/easyfig/README | 15 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/easyfig/easyfig.pdf | bin | 0 -> 186936 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/easyfig/easyfig.dtx | 439 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/easyfig/easyfig.ins | 10 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/easyfig/easyfig.sty | 133 |
5 files changed, 597 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/easyfig/README b/Master/texmf-dist/doc/latex/easyfig/README new file mode 100644 index 00000000000..ca55ae25a64 --- /dev/null +++ b/Master/texmf-dist/doc/latex/easyfig/README @@ -0,0 +1,15 @@ +LaTeX package 'easyfig' +~~~~~~~~~~~~~~~~~~~~~~~ +Copyright (c) 2011 by Martin Scharrer <martin@scharrer.me> +WWW: http://latex.scharrer.me/ +CTAN: http://www.ctan.org/pkg/easyfig +Code repository: https://bitbucket.org/martin_scharrer/easyfig + +Provides \Figure[<key=value pairs>]{<image filename>} to easily include +an image as figure in the most common form (centered and with caption and label). +Caption and label can be set using the 'caption' and 'label' key. The label defaults +to 'fig:<image filename>' if not used. + +The package uses the authors other package 'adjustbox' to center and image and to +allow for easy further modifications. + diff --git a/Master/texmf-dist/doc/latex/easyfig/easyfig.pdf b/Master/texmf-dist/doc/latex/easyfig/easyfig.pdf Binary files differnew file mode 100644 index 00000000000..e82cfdcb8f7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/easyfig/easyfig.pdf diff --git a/Master/texmf-dist/source/latex/easyfig/easyfig.dtx b/Master/texmf-dist/source/latex/easyfig/easyfig.dtx new file mode 100644 index 00000000000..02576e385b5 --- /dev/null +++ b/Master/texmf-dist/source/latex/easyfig/easyfig.dtx @@ -0,0 +1,439 @@ +% \iffalse meta-comment +%<=*COPYRIGHT> +%% Copyright (C) 2011 by Martin Scharrer <martin@scharrer.me> +%% --------------------------------------------------------------------------- +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Martin Scharrer. +%% +%% This work consists of the files easyfig.dtx and easyfig.ins +%% and the derived filebase easyfig.sty. +%% +%<=/COPYRIGHT> +% \fi +% +% \iffalse +%<*driver> +\ProvidesFile{easyfig.dtx}[% +%<=*DATE> + 2011/10/31 +%<=/DATE> +%<=*VERSION> + v1.0 +%<=/VERSION> + Easily include images as figures] +\documentclass{ydoc} +\GetFileInfo{easyfig.dtx} +\usepackage{easyfig}[\filedate] +\usepackage{flafter} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\OnlyDescription +\optionaloff +\begin{document} + \DocInput{\jobname.dtx} + \PrintChanges + \PrintIndex +\end{document} +%</driver> +% \fi +% +% \CheckSum{0} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{<+version+>}{<+date+>}{<+log+>} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% \GetFileInfo{easyfig.dtx} +% \author{Martin Scharrer} +% \email{martin@scharrer.me} +% \ifdefined\repository +% \repository{https://bitbucket.org/martin_scharrer/easyfig} +% \fi +% +% \maketitle +% +% \begin{abstract}\noindent +% This package aims to simplify the most common usage of \env{figure} environments +% to include a single image with a caption and label. +% \end{abstract} +% +% \section{Introduction} +% A very high percentage of all \LaTeX\ figures aim to simply display a simple image with a caption and label. +% A common way to code this is: +% \begin{lstlisting}[gobble=4,numbers=none] +% \begin{figure} +% \centering +% \includegraphics[<options>]{<filename>} +% \caption{<caption text>} +% \label{<label>} +% \end{figure} +% \end{lstlisting} +% +% This package provides an easy and short way to include figures like this. At the moment only single image figures +% are supported but it is planned to also support common 1x2 and 2x1 figures in future releases. +% +% \iffalse +% \section{Dependecies} +% This package uses the following packages: \pkg{xkeyval}, \pkg{adjustbox} (which uses \pkg{graphicx}) and \pkg{ifetex}. +% \fi +% +% \section{Usage} +% \subsection*{Macros} +% \DescribeMacro\Figure[<key=value pairs>]{<image filename>} +% \DescribeMacro\Figure*[<key=value pairs>]{<image filename>} +% The macro creates a \env{figure} environment where the given image file is included using \Macro\includegraphics wrapped in an \env{adjustbox} environment. +% By default the image is centered and all keys which are not known by \Macro\Figure are passed to the internal \env{adjustbox} environment. This accepts all normal +% \Macro\includegraphics keys as well as many more. The starred version uses the \env{figure*} environment instead which will insert the figure over both columns in \opt{twocolumn} mode. +% +% \noindent +% Usually this macro is used as follows:\nopagebreak +% \begingroup +% \leftmargin=0pt +% \rightmargin=0pt +% \begin{macroquote} +% \Figure['caption='{My caption},label=fig:mypic]{myimage}\\ +% \Figure['caption='{My caption}]{myimage}\\ +% \Figure['caption='{My caption},label=fig:mypic,placement=ht]{myimage} +% \end{macroquote} +% \endgroup +% +% \DescribeMacro\easyfigdefault{<key=value pairs (before)>} +% \DescribeMacro\easyfigdefault*{<key=value pairs (after)>} +% Defines a list of key/value pairs which should be used by default. The normal version adds the pairs before the one +% given with the optional argument of \Macro\Figure, while the starred version adds them after these. +% If these macros are used more then once the old default settings are overwritten. +% This feature is similar to \Macro\adjustboxset from the used \pkg{adjustbox} package, but the keys are only affecting \Macro\Figure macros and do not stack. +% By default the \emph{before} key list is empty and the \emph{after} list is set to \Key{center} which centers the image around the \Macro\linewidth, after any other +% transformation is applied. The default centering can be deleted using \Macro\easyfigdefault*{}. +% +% +% \subsection*{Keys} +% The following keys exist to control the elements of the figure. All other keys are passed to the inner \env{adjustbox} environment from the \pkg{adjustbox} package. +% +% \DescribeKey{caption}'='<caption> +% Sets the \Macro\caption of the figure. +% +% \DescribeKey{captionabove}'='<caption> +% Sets the \Macro\caption of the figure which is placed above the figure instead of the default placement below it. +% +% \DescribeKey{shortcaption}'='<short caption> +% Sets the short version of the caption, i.e. the optional argument of \Macro\caption, used for the table-of-figures. +% This key only has an effect if either \Key{caption} or \Key{captionabove} is used as well. However, the order of keys is not meaningful. +% +% \DescribeKey{label}'='<label> +% Sets the \Macro\label of the figure. The order of this key and \Key{caption} or \Key{captionabove} is not meaningful. +% If the figure has a caption but this key is not used, a default label `\MacroArgs'fig:'<image filename>\relax' is used instead. +% +% \DescribeKey{placement}'='<placement characters> +% This key defines the requested placement of the figure. The value is then passed to the optional argument of \env{figure} or \env{figure*}. +% Valid positioning characters are `|p|' (page), `|t|' (top), `|b|' (bottom), `|h|' (here) and `|!|' (force) and any additional characters defined by packages (like `|H|'). +% +% \DescribeKey{twocolumn} +% \DescribeKey{twocolumn}'=true|false' +% This boolean key will use the \env{figure*} environment which make the figure span over both columns in a \opt{twocolumn} document. It has the same effect as using \Macro\Figure*, but allows +% to switch between this two modes for all figures using \Macro\easyfigdefault. When used without a value `|true|' is assumed. +% Any other value as `|true|' switches to one-column mode, even if \Macro\Figure* was used. +% +% \subsection*{Notable \pkg{adjustbox} Keys} +% The following keys are mentioned here because they are might be often used for images inside figures. Please see the \pkg{adjustbox} manual for further details and keys. +% In addition all \Macro\includegraphics keys as mentioned in the \href{http://www.ctan.org/pkg/grfguide}{grfguide} can of course be used. +% +% \DescribeKey{center}'='<length> +% \DescribeKey{left}'='<length> +% \DescribeKey{right}'='<length> +% Aligns the image at the center or to the left or right. The \emph{optional} length defines the final width in with the image is aligned. By default the current \Macro\linewidth is used, which +% inside figures is normally identical to the \Macro\textwidth. If the image is wider than the given width it will overlap accordantly, i.e. on both sites, on the right or on the left, respectively. +% As mentioned above by default \Key{center} is applied to all figures. This replaces the normally used \Macro\centering. +% +% \DescribeKey{width}'='<length> +% \DescribeKey{height}'='<length> +% \DescribeKey{totalheight}'='<length> +% \DescribeKey{min width}'='<length> +% \DescribeKey{min height}'='<length> +% \DescribeKey{min size}'='{<length>}{<length>} +% \DescribeKey{max width}'='<length> +% \DescribeKey{max height}'='<length> +% \DescribeKey{max size}'='{<length>}{<length>} +% Can be used to set the nominal/minimal/maximum width and height of the image. +% +% \DescribeKey{frame} +% \DescribeKey{frame}'='<length> +% Adds a tight frame around the image. +% +% \DescribeKey{fbox} +% \DescribeKey{fbox}'='<length> +% \DescribeKey{fbox}'='<length>~<sep> +% Adds a frame around the image. +% +% \DescribeKey{margin}'='<all sites> +% \DescribeKey{margin}'='<left/right>~<top/bottom> +% \DescribeKey{margin}'='<llx>~<lly>~<urx>~<ury> +% This key can be used to add a margin (white space) around the image. +% +% +% \section{Examples} +% +% \subsubsection{Simple figure with an image and caption, automated label} +% A default label `|fig:tiger|' is used here. +% \par\smallskip\noindent +% \Macro\Figure['width=5cm,caption={A tiger}']{tiger} +% \Figure[width=5cm,caption={A tiger}]{tiger} +% +% \subsubsection{Simple figure with an image and caption, manual label} +% Normal usage with a manual label. +% \par\smallskip\noindent +% \Macro\Figure['width=5cm,caption={Second tiger},label=fig:mytiger']{tiger} +% \Figure[width=5cm,caption={Second tiger},label=fig:mytiger]{tiger} +% +% \subsubsection{Usage of other keys} +% Adds a frame around the image which is rotated a little. +% \par\smallskip\noindent +% \Macro\Figure['width=5cm,angle=10,caption={Another tiger},frame']{tiger} +% \Figure[width=5cm,angle=10,caption={Another tiger},frame]{tiger} +% +% \StopEventually{} +% \clearpage +% \section{Implementation} +% +% \iffalse +%<*easyfig.sty> +% \fi +% \begin{macrocode} +%<!COPYRIGHT> +\ProvidesPackage{easyfig}[% +%<!DATE> +%<!VERSION> +%<*DRIVER> + 2099/01/01 develop +%</DRIVER> + Easy way to include figures] +% \end{macrocode} +% +% \begin{macrocode} +\RequirePackage{adjustbox} +\RequirePackage{xkeyval} +\RequirePackage{ifetex} +% \end{macrocode} +% +% \begin{macrocode} +\let\easyfig@caption\@gobble +\let\easyfig@captionabove\@gobble +\let\easyfig@placement\@empty +\let\easyfig@default\@empty +\let\easyfig@default@end\@empty +\let\easyfig@shortcaption\@empty +\def\easyfig@env{{figure}} +% \end{macrocode} +% +% \begin{macro}{\easyfigdefault} +% \begin{macrocode} +\newcommand*{\easyfigdefault}{% + \@ifstar + {\def\easyfig@default@end}% + {\def\easyfig@default}% +} +\easyfigdefault*{center} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\easyfig@label} +% \begin{macrocode} +\def\easyfig@label#1{% + \@ifundefined {easyfig@r@fig:#1}{% + \label{fig:#1}% + \global\@namedef{easyfig@r@fig:#1}{}% + }{}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{key}{easyfig}{caption} +% \begin{macrocode} +\define@key{easyfig}{caption}{% + \def\easyfig@caption##1{\expandafter\caption\easyfig@shortcaption{#1}\easyfig@label{##1}}% + \let\easyfig@captionabove\@gobble +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{easyfig}{shortcaption} +% \begin{macrocode} +\define@key{easyfig}{shortcaption}{% + \def\easyfig@shortcaption{[{#1}]}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{easyfig}{captionabove} +% \begin{macrocode} +\define@key{easyfig}{captionabove}{% + \let\easyfig@caption\@gobble + \def\easyfig@captionabove##1{{% + \@tempdima=\abovecaptionskip + \abovecaptionskip=\belowcaptionskip + \belowcaptionskip=\@tempdima + \expandafter\caption\easyfig@shortcaption{#1}% + \easyfig@label{##1}% + }}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{easyfig}{label} +% \begin{macrocode} +\define@key{easyfig}{label}{% + \def\easyfig@label##1{\label{#1}}% +} +% \end{macrocode} +% \end{key} +% +% +% \begin{key}{easyfig}{placement} +% \begin{macrocode} +\define@key{easyfig}{placement}{% + \def\easyfig@placement{[#1]}% +} +% \end{macrocode} +% \end{key} +% +% \begin{key}{easyfig}{twocolumn} +% \begin{macrocode} +\define@key{easyfig}{twocolumn}[true]{% + \begingroup + \def\@tempa{#1}% + \def\@tempb{true}% + \ifx\@tempa\@tempb + \endgroup + \def\easyfig@env{{figure*}}% + \else + \endgroup + \def\easyfig@env{{figure}}% + \fi +} +% \end{macrocode} +% \end{key} +% +% \begin{macro}{\Figure} +% \begin{macrocode} +\newcommand{\Figure}{% + \begingroup + \@ifstar + {\def\easyfig@env{{figure*}}\@Figure}% + {\@Figure}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\ifetex +% \end{macrocode} +% +% Efficient $\epsilon$-\TeX\ definition: +% +% \begin{macro}{\easyfig@expandonce} +% \begin{macrocode} +\def\easyfig@expandonce#1{% + \expandafter\unexpanded\expandafter{#1}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@Figure} +% \begin{macrocode} +\newcommand{\@Figure}[2][]{% + \edef\@tempa{% + \noexpand\setkeys*{easyfig}{% + \easyfig@expandonce\easyfig@default,% + \unexpanded{#1},% + \easyfig@expandonce\easyfig@default@end + }% + \noexpand\begin\easyfig@env% + \ifx\easyfig@placement\@empty\else + [\easyfig@placement]% + \fi + }% + \@tempa + \easyfig@captionabove{#2}% + \edef\@tempa{\noexpand\begin{adjustbox}{\easyfig@expandonce\XKV@rm}}% + \@tempa + \includegraphics{#2}% + \end{adjustbox}% + \easyfig@caption{#2}% + \expandafter\end\easyfig@env% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\else +% \end{macrocode} +% +% Fall-back definition for distributions which do not support $\epsilon$-\TeX: +% +% \begin{macro}{\@Figure} +% \begin{macrocode} +\newcommand{\@Figure}[2][]{% + \def\@tempa{\setkeys*{easyfig}}% + \expandafter\toks@\expandafter{\easyfig@default,#1}% + \expandafter\expandafter\expandafter\toks@ + \expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks@\expandafter,\easyfig@default@end}% + \expandafter\@tempa\expandafter{\the\toks@} + \edef\@tempa{\noexpand\begin{\easyfig@env}}% + \expandafter\@tempa\easyfig@placement + \easyfig@captionabove{#2}% + \def\@tempa{\begin{adjustbox}}% + \expandafter\def\expandafter\@tempb\expandafter{\expandafter{\XKV@rm}}% + \expandafter\@tempa\@tempb + \includegraphics{#2}% + \end{adjustbox}% + \easyfig@caption{#2}% + \expandafter\end\easyfig@env% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macrocode} +\fi +% \end{macrocode} +% \iffalse +%</easyfig.sty> +% \fi +% +% \Finale +\endinput diff --git a/Master/texmf-dist/source/latex/easyfig/easyfig.ins b/Master/texmf-dist/source/latex/easyfig/easyfig.ins new file mode 100644 index 00000000000..5cfc7c95c1d --- /dev/null +++ b/Master/texmf-dist/source/latex/easyfig/easyfig.ins @@ -0,0 +1,10 @@ +\input ydocstrip.tex +\keepsilent +\askforoverwritefalse + +\generate{% + \file{easyfig.sty}{\nopreamble\from{easyfig.dtx}{easyfig.sty}}% +} +\endbatchfile + +%% vim: ft=tex diff --git a/Master/texmf-dist/tex/latex/easyfig/easyfig.sty b/Master/texmf-dist/tex/latex/easyfig/easyfig.sty new file mode 100644 index 00000000000..cdd34a5978e --- /dev/null +++ b/Master/texmf-dist/tex/latex/easyfig/easyfig.sty @@ -0,0 +1,133 @@ +%% Copyright (C) 2011 by Martin Scharrer <martin@scharrer.me> +%% --------------------------------------------------------------------------- +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Martin Scharrer. +%% +%% This work consists of the files easyfig.dtx and easyfig.ins +%% and the derived filebase easyfig.sty. +%% +\ProvidesPackage{easyfig}[% + 2011/10/31 + v1.0 + Easy way to include figures] +\RequirePackage{adjustbox} +\RequirePackage{xkeyval} +\RequirePackage{ifetex} +\let\easyfig@caption\@gobble +\let\easyfig@captionabove\@gobble +\let\easyfig@placement\@empty +\let\easyfig@default\@empty +\let\easyfig@default@end\@empty +\let\easyfig@shortcaption\@empty +\def\easyfig@env{{figure}} +\newcommand*{\easyfigdefault}{% + \@ifstar + {\def\easyfig@default@end}% + {\def\easyfig@default}% +} +\easyfigdefault*{center} +\def\easyfig@label#1{% + \@ifundefined {easyfig@r@fig:#1}{% + \label{fig:#1}% + \global\@namedef{easyfig@r@fig:#1}{}% + }{}% +} +\define@key{easyfig}{caption}{% + \def\easyfig@caption##1{\expandafter\caption\easyfig@shortcaption{#1}\easyfig@label{##1}}% + \let\easyfig@captionabove\@gobble +} +\define@key{easyfig}{shortcaption}{% + \def\easyfig@shortcaption{[{#1}]}% +} +\define@key{easyfig}{captionabove}{% + \let\easyfig@caption\@gobble + \def\easyfig@captionabove##1{{% + \@tempdima=\abovecaptionskip + \abovecaptionskip=\belowcaptionskip + \belowcaptionskip=\@tempdima + \expandafter\caption\easyfig@shortcaption{#1}% + \easyfig@label{##1}% + }}% +} +\define@key{easyfig}{label}{% + \def\easyfig@label##1{\label{#1}}% +} +\define@key{easyfig}{placement}{% + \def\easyfig@placement{[#1]}% +} +\define@key{easyfig}{twocolumn}[true]{% + \begingroup + \def\@tempa{#1}% + \def\@tempb{true}% + \ifx\@tempa\@tempb + \endgroup + \def\easyfig@env{{figure*}}% + \else + \endgroup + \def\easyfig@env{{figure}}% + \fi +} +\newcommand{\Figure}{% + \begingroup + \@ifstar + {\def\easyfig@env{{figure*}}\@Figure}% + {\@Figure}% +} +\ifetex +\def\easyfig@expandonce#1{% + \expandafter\unexpanded\expandafter{#1}% +} +\newcommand{\@Figure}[2][]{% + \edef\@tempa{% + \noexpand\setkeys*{easyfig}{% + \easyfig@expandonce\easyfig@default,% + \unexpanded{#1},% + \easyfig@expandonce\easyfig@default@end + }% + \noexpand\begin\easyfig@env% + \ifx\easyfig@placement\@empty\else + [\easyfig@placement]% + \fi + }% + \@tempa + \easyfig@captionabove{#2}% + \edef\@tempa{\noexpand\begin{adjustbox}{\easyfig@expandonce\XKV@rm}}% + \@tempa + \includegraphics{#2}% + \end{adjustbox}% + \easyfig@caption{#2}% + \expandafter\end\easyfig@env% + \endgroup +} +\else +\newcommand{\@Figure}[2][]{% + \def\@tempa{\setkeys*{easyfig}}% + \expandafter\toks@\expandafter{\easyfig@default,#1}% + \expandafter\expandafter\expandafter\toks@ + \expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks@\expandafter,\easyfig@default@end}% + \expandafter\@tempa\expandafter{\the\toks@} + \edef\@tempa{\noexpand\begin{\easyfig@env}}% + \expandafter\@tempa\easyfig@placement + \easyfig@captionabove{#2}% + \def\@tempa{\begin{adjustbox}}% + \expandafter\def\expandafter\@tempb\expandafter{\expandafter{\XKV@rm}}% + \expandafter\@tempa\@tempb + \includegraphics{#2}% + \end{adjustbox}% + \easyfig@caption{#2}% + \expandafter\end\easyfig@env% + \endgroup +} +\fi +\endinput +%% +%% End of file `easyfig.sty'. |