summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/draftfigure
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/draftfigure
Initial commit
Diffstat (limited to 'macros/latex/contrib/draftfigure')
-rw-r--r--macros/latex/contrib/draftfigure/README.md37
-rw-r--r--macros/latex/contrib/draftfigure/draftfigure.pdfbin0 -> 178316 bytes
-rw-r--r--macros/latex/contrib/draftfigure/draftfigure.sty123
-rw-r--r--macros/latex/contrib/draftfigure/draftfigure.tex409
4 files changed, 569 insertions, 0 deletions
diff --git a/macros/latex/contrib/draftfigure/README.md b/macros/latex/contrib/draftfigure/README.md
new file mode 100644
index 0000000000..ce292a23d1
--- /dev/null
+++ b/macros/latex/contrib/draftfigure/README.md
@@ -0,0 +1,37 @@
+draftfigure
+=======
+
+a package to replace figures with a white box and additional features
+---
+_2017/07/19 v0.2_
+
+Copyright (c) 2017 Lukas C. Bossert
+
+[info@biblatex-archaeologie.de](mailto:info@biblatex-archaeologie.de) | [www.digitales-altertum.de](http://www.digitales-altertum.de)
+
+With this package you can control the outcome of a figure which is set to `draft` and modify the display with various options.
+
+---
+
+This package contains:
+
+documentation:
+
+- draftfigure.pdf
+- draftfigure.tex
+
+style-file:
+
+- draftfigure.sty
+
+
+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](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 [Lukas C. Bossert](https://github.com/LukasCBossert).
+
diff --git a/macros/latex/contrib/draftfigure/draftfigure.pdf b/macros/latex/contrib/draftfigure/draftfigure.pdf
new file mode 100644
index 0000000000..2158779090
--- /dev/null
+++ b/macros/latex/contrib/draftfigure/draftfigure.pdf
Binary files differ
diff --git a/macros/latex/contrib/draftfigure/draftfigure.sty b/macros/latex/contrib/draftfigure/draftfigure.sty
new file mode 100644
index 0000000000..ab2bf74851
--- /dev/null
+++ b/macros/latex/contrib/draftfigure/draftfigure.sty
@@ -0,0 +1,123 @@
+% draftfigure --%
+% modifying drafted figures
+% Copyright (c) 2017 Lukas C. Bossert
+%
+% 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.
+ \def\df@date{2017/07/19}
+ \def\df@version{0.2}
+ \def\df@styid{\df@date\space v\df@version\space draftfigure (LCB)}
+ \let\dfdate\df@date
+ \let\dfversion\df@version
+
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+\ProvidesPackage{draftfigure}[\df@styid]
+
+\RequirePackage{graphicx}
+\RequirePackage{etoolbox}
+\RequirePackage{xkeyval}
+\RequirePackage{calc}
+
+\newbool{df@filename}
+\newbool{df@content}
+\newbool{df@noframe}
+
+\newlength\df@height
+\newlength\df@length
+
+\providecommand*\df@size{}
+\providecommand*\df@style{}
+\providecommand*\df@font{}
+\providecommand*\df@position{}
+\providecommand*\df@content{}
+
+
+\patchcmd{\Gin@setfile}{\expandafter\strip@prefix\meaning\@tempa}{\@draftfigure}{}{}
+
+
+\providecommand\df@noframe
+
+%% Declare a package option
+\DeclareOptionX{content}{\def\df@content{#1}}
+\DeclareOptionX{filename}[true]{\csuse{bool#1}{df@filename}
+
+}
+\DeclareOptionX{size}[small]{\def\df@size{\csname df@size@#1\endcsname}}
+\DeclareOptionX{style}[sf]{\def\df@style{\csname df@style@#1\endcsname}}
+\DeclareOptionX{position}[right]{\def\df@position{\csname df@position@#1\endcsname}}
+\DeclareOptionX{allfiguresdraft}[true]{\setkeys{Gin}{draft=#1}}
+\DeclareOptionX{noframe}[true]{\csuse{bool#1}{df@noframe}
+ \ifbool{df@noframe}{%
+ \patchcmd\Gin@setfile{\vrule\hss}{\vrule\@width\z@\hss}{}{}%left
+ \patchcmd\Gin@setfile{\hss\vrule}{\hss\vrule\@width\z@}{}{}%right
+ \patchcmd\Gin@setfile{\hrule\@width}{\hrule\@height\z@\@width}{}{}%top
+ \patchcmd\Gin@setfile{\vss\hrule}{\vss\hrule\@height\z@}{}{}%bottom
+}{}}
+
+%% predefined styles
+\providecommand\df@style@normal{\normalfont}
+\providecommand\df@style@sf{\sffamily}
+\providecommand\df@style@sc{\scshape}
+\providecommand\df@style@bf{\bfseries}
+\providecommand\df@style@it{\itshape}
+\providecommand\df@style@tt{\ttfamily}
+\providecommand\df@style@rm{\rmfamily}
+
+\providecommand\df@size@tiny{\tiny}
+\providecommand\df@size@scriptsize{\scriptsize}
+\providecommand\df@size@small{\small}
+\providecommand\df@size@footnotesize{\footnotesize}
+\providecommand\df@size@normal{\normalsize}
+\providecommand\df@size@large{\large}
+\providecommand\df@size@Large{\Large}
+\providecommand\df@size@Large{\LARGE}
+\providecommand\df@size@huge{\huge}
+
+\providecommand\df@position@top{}%% fix me
+\providecommand\df@position@center{\centering}
+\providecommand\df@position@bottom{}%% fix me
+\providecommand\df@position@right{\raggedleft}
+\providecommand\df@position@left{\raggedright}
+
+%% Process the options given to the package
+\ProcessOptionsX
+
+\define@key{draftfigure}{code}{%
+ \def\df@style{#1}}
+\define@key{draftfigure}{noframe}[true]{%
+ \csuse{bool#1}{df@noframe}}
+\define@key{draftfigure}{filename}[true]{%
+ \csuse{bool#1}{df@filename}}
+\define@key{draftfigure}{content}[]{%
+ \def\df@content{#1}}
+\define@key{draftfigure}{style}[normal]{%
+ \def\df@style{\csname df@style@#1\endcsname}}
+\define@key{draftfigure}{position}[left]{%
+ \def\df@position{\csname df@position@#1\endcsname}}
+\define@key{draftfigure}{size}[normal]{%
+ \def\df@size{\csname df@size@#1\endcsname}}
+
+\newcommand\setdf[1]{\setkeys{draftfigure}{#1}}
+
+\def\@draftfigure{%
+\setlength\df@height{\Gin@nat@height}%
+\setlength\df@length{\Gin@req@width}%
+\begin{minipage}[c][\df@height-5pt][c]{\df@length-5pt}%
+ \sffamily%
+ \df@position%
+ \df@size%
+ \df@style%
+\df@content%
+ \ifbool{df@filename}{%
+ \ifdef{\df@content}%
+ {\par}%
+ {}%
+ \expandafter\strip@prefix\meaning\@tempa}%
+ {}%
+\end{minipage}}%
+\endinput
diff --git a/macros/latex/contrib/draftfigure/draftfigure.tex b/macros/latex/contrib/draftfigure/draftfigure.tex
new file mode 100644
index 0000000000..10fcb21f10
--- /dev/null
+++ b/macros/latex/contrib/draftfigure/draftfigure.tex
@@ -0,0 +1,409 @@
+% \draftfigure --%
+% modifying drafted figures
+% Copyright (c) 2017 Lukas C. Bossert
+%
+% 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.
+% !TEX program = lualatex
+\documentclass[a4paper,
+10pt,
+english
+]{ltxdoc}
+
+
+\input{draftfigure-preamble.tex}
+\newcommand\df{draftfigure\xspace}
+\newcommand\dfstring{|draftfigure|\xspace}
+\setkeys{Gin}{width=.5\linewidth}
+
+\begin{document}
+\AddRevision{2017-07-19}{Improvement of coding}{Lukas C. Bossert}
+\AddRevision{2017-05-07}{Documentation completed}{Lukas C. Bossert}
+\AddRevision{2017-05-06}{Initial release}{Lukas C. Bossert}
+
+
+\title{\texttt{\df} -- \\ modifying drafted figures\footnote{%
+For further information about the code visit \href{https://github.com/LukasCBossert/draftfigure}{https://github.com/LukasCBossert/draftfigure}
+Comments and criticisms are welcome.}}
+\author{Lukas C. Bossert\\{\small \href{mailto:lukas@digitales-altertum.de}{lukas@digitales-altertum.de}}}
+\date{Version: \dfdate{} (\dfversion)}
+\maketitle
+
+\begin{abstract}
+\noindent This package allows you to customize the outcome of drafted figures.
+\end{abstract}
+
+
+\begin{multicols}{2}
+\footnotesize\parskip=0mm \tableofcontents
+\end{multicols}
+
+\section{Installation}
+\dfstring is part of the distributions MiK\TeX \footnote{Website: \url{http://www.miktex.org}.}
+and \TeX Live\footnote{Website: \url{http://www.tug.org/texlive}.}~-- thus, you
+can easily install it using the respective package manager.
+If you would like to
+install \dfstring manually, do the following:
+Download the folder \dfstring with all relevant files from the CTAN-server\footnote{\url{https://www.ctan.org/pkg/\df}} and copy the content of the |zip|-file to the \texttt{\$LOCALTEXMF} directory of
+ your system.\footnote{If you don't know what that is, have a look at
+\url{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tds} or
+\url{http://mirror.ctan.org/tds/tds.html}.}
+Refresh your filename database.
+
+Here is some additional information from the UK \TeX\ FAQ:
+\begin{itemize}[nosep,after=\vspace{-\baselineskip} ]
+ \item \href{%
+ http://www.tex.ac.uk/cgi-bin/texfaq2html?label=install-where}{%
+ Where to install packages}
+ \item \href{%
+ http://www.tex.ac.uk/cgi-bin/texfaq2html?label=inst-wlcf}{%
+ Installing files \enquote{where \LaTeX /TeX\ can find them}}
+ \item \href{%
+ http://www.tex.ac.uk/cgi-bin/texfaq2html?label=privinst}{%
+ \enquote{Private} installations of files}
+\end{itemize}
+
+%%introduction from biblatex-dw copied and applied. might to be rewritten.
+
+\clearpage
+\section{Status Quo}
+
+Usually you see all of your images in your PDF:
+\begin{examplebox}
+\begin{figure}[H]
+ \centering
+ \includegraphics{example-image-a}
+ \caption{A}
+ \includegraphics{example-image-b}
+ \caption{B}
+ \includegraphics{example-image-c}
+ \caption{C}
+\end{figure}
+\end{examplebox}
+Sometimes you do not need to see the images or want to omit them due to faster compiling or you do not have the right to publish them.
+
+
+You can \enquote{switch off} the images by using the option |draft| either with
+|\documentclass[draft]|\marg{class}
+%\cs{documentclass}\oarg{draft}\marg{clss}
+or with
+|\usepackage[draft]{graphicx}|.
+%\cs{usepackage}\oarg{draft}\marg{graphicx}
+
+
+If you do not like the outcome with the filename and its path written with |\ttfamily| but still need the same size of the image in the text then use this package \dfstring to modify the outcome.
+\clearpage
+
+\section{Usage}
+ \DescribeMacro{draftfigure} The name of the package is \dfstring which has to be activated in the preamble.
+
+\begin{code}
+\usepackage[*@\meta{further options}@*]{draftfigure}
+\end{code}
+Without any further options you will now get white boxes instead of the images.
+\begin{examplebox}
+\begin{figure}[H]\setkeys{Gin}{draft=true}
+ \centering
+ \includegraphics{example-image-a}
+ \caption{A}
+ \includegraphics{example-image-b}
+ \caption{B}
+ \includegraphics{example-image-c}
+ \caption{C}
+\end{figure}
+\end{examplebox}
+
+\clearpage
+
+\section{Options}
+If you like the plain white boxes you don’t need to do anything else. But if you like to change that use one or more of the following options.
+
+So let’s see some action.
+\subsection{Preamble}
+The following options are set in the preamble and considered globally for all figures.
+\subsubsection{content}
+\DescribeMacro{content}
+With this option you can set an individual text which will be displayed in the white box.
+\begin{code}
+\usepackage[%
+ content = {This figure is omitted due to missing copyrights.},%
+ ]{draftfigure}
+\end{code}
+\begin{examplebox}
+\begin{figure}[H]
+ \setkeys{draftfigure}{content = {This figure is omitted due to missing copyrights.}}
+ \setkeys{Gin}{draft=true}
+ \centering
+ \includegraphics{example-image-a}
+ \caption{A}
+ \includegraphics{example-image-b}
+ \caption{B}
+\end{figure}
+\end{examplebox}
+\clearpage
+\subsubsection{filename}
+\DescribeMacro{filename}
+Activating this option with |true| the filename will be displayed in the white box.
+If you also have defined some text for |content| the filename will appear one line below of |content|.
+\begin{code}
+\usepackage[%
+ filename,%
+ ]{draftfigure}
+\end{code}
+\begin{examplebox}
+\begin{figure}[H]
+ \setkeys{Gin}{draft=true}
+ \setkeys{draftfigure}{filename}
+ \centering
+ \includegraphics{example-image-a}
+ \caption{A}
+ \includegraphics{example-image-b}
+ \caption{B}
+ \includegraphics{example-image-c}
+ \caption{C}
+\end{figure}
+\end{examplebox}
+\clearpage
+\DescribeMacro{filename}
+\DescribeMacro{content}
+And with some text in |content| it will look like this:
+\begin{code}
+\usepackage[%
+ filename,%
+ content={no image available}
+ ]{draftfigure}
+\end{code}
+\begin{examplebox}
+\begin{figure}[H]
+ \setkeys{Gin}{draft=true}
+ \setkeys{draftfigure}{filename,
+ content={no image available}}
+ \centering
+ \includegraphics{example-image-a}
+ \caption{A}
+ \includegraphics{example-image-b}
+ \caption{B}
+ \includegraphics{example-image-c}
+ \caption{C}
+\end{figure}
+\end{examplebox}
+\clearpage
+\subsubsection{style}
+\DescribeMacro{style} This defines the font style of the text of |content| or |filename|.
+You can chose one of the following styles:
+\begin{multicols}{3}
+\begin{itemize}
+ \item[sf] |\sffamily|
+ \item[tt] |\ttfamily|
+ \item[rm] |\rmfamily|
+ \item[normal] |\normalfont|
+ \item[bf] |\bfseries|
+ \item[it] |\itshape|
+ \item[sc] |\scshape|
+\end{itemize}
+\end{multicols}
+Default is |sf|.
+\DescribeMacro{content}
+\DescribeMacro{style}
+\begin{code}
+\usepackage[%
+ content={hidden image},
+ style = {bf},%
+ ]{draftfigure}
+\end{code}
+\begin{examplebox}
+\begin{figure}[H]
+ \setkeys{Gin}{draft=true}
+ \setkeys{draftfigure}{style={bf},content={hidden image}}
+ \centering
+ \includegraphics{example-image-a}
+ \caption{A}
+ \includegraphics{example-image-b}
+ \caption{B}
+ % \includegraphics{example-image-c}
+ % \caption{C}
+\end{figure}
+\end{examplebox}
+\clearpage
+\subsubsection{size}
+\DescribeMacro{size}
+You can also define the text size of |content| with predefined values:
+\begin{multicols}{2}
+\begin{itemize}
+ \item[tiny] |\tiny|
+ \item[scriptsize] |\scriptsize|
+ \item[small] |\small|
+ \item[footnotesize] |\footnotesize|
+ \item[normal] |\normalsize|
+ \item[large] |\large|
+ \item[Large] |\Large|
+ \item[LARGE] |\LARGE|
+ \item[huge] |\huge|
+\end{itemize}
+\end{multicols}
+Default is |small|.
+\DescribeMacro{content}
+\DescribeMacro{size}
+\begin{code}
+\usepackage[%
+ content={text instead of an image},
+ size = {huge},%
+ ]{draftfigure}
+\end{code}
+\begin{examplebox}
+\begin{figure}[H]
+ \setkeys{Gin}{draft=true, width =.6\linewidth}
+ \setkeys{draftfigure}{
+ content={text instead of an image},
+ size = {huge},%
+ }
+ \centering
+ \includegraphics{example-image-a}
+ \caption{A}
+ \includegraphics{example-image-b}
+ \caption{B}
+ % \includegraphics{example-image-c}
+ % \caption{C}
+\end{figure}
+\end{examplebox}
+
+\clearpage
+
+\subsubsection{position}
+\DescribeMacro{position}
+You can also decide where your text from |content| has to be placed
+\begin{multicols}{3}
+\begin{itemize}
+ \item[left] |\raggedright|
+ \item[center] |\centering|
+ \item[right] |\raggedleft|
+\end{itemize}
+\end{multicols}
+Default is |left|.
+\DescribeMacro{content}
+\DescribeMacro{position}
+\begin{code}
+\usepackage[%
+ content={positioning},
+ position = {center},%
+ ]{draftfigure}
+\end{code}
+\begin{examplebox}
+\begin{figure}[H]
+ \setkeys{Gin}{draft=true,width=.45\linewidth}
+ \setkeys{draftfigure}{
+ content={positioning},
+ position = {center},%
+ }
+ \centering
+ \includegraphics{example-image-a}
+ \caption{A}
+ \includegraphics{example-image-b}
+ \caption{B}
+ \includegraphics{example-image-c}
+ \caption{C}
+\end{figure}
+\end{examplebox}
+
+\clearpage
+\subsubsection{allfiguresdraft}
+\DescribeMacro{allfiguresdraft}
+Enabling |allfiguresdraft| all figures in your text will be shown as a white box. This is the same as |\usepackage[draft]{graphicx}|.
+
+\subsubsection{noframe}
+\DescribeMacro{noframe}
+The white boxes of the replaced figures are shown with no frame and no border, but still same sizes as the figure it represents.
+
+
+\subsection{Individually possible options}
+
+Since you can also set |draft| to individual images you can also pass some of the options of \dfstring to individual images.
+
+\DescribeMacro{style}
+\DescribeMacro{size}
+\DescribeMacro{position}
+\DescribeMacro{content}
+\DescribeMacro{filename}These are |style|, |size|, |position|, |content|, |filename|.
+
+In the preamble there is this setup
+\begin{code}
+\usepackage{draftfigure}
+\end{code}
+So no options are enabled globally.
+
+To pass an option to an image you need to insert in the |figure|-environment the following:
+\begin{code}
+\setkeys{draftfigure}*@\marg{options}@*
+\end{code}
+or -- a little bit shorter:
+\begin{code}
+\setdf*@\marg{options}@*
+\end{code}
+
+The overview starts on the next page.
+\clearpage
+\setkeys{Gin}{width=.4\linewidth}
+\begin{codeexample}
+\begin{figure}[H]
+ \centering
+ \setkeys{draftfigure}{content={white box}}
+ \includegraphics[draft]{example-image-a}
+ \caption{A}\label{A}
+ \setkeys{draftfigure}{filename=true}
+ \includegraphics[draft]{example-image-b}
+ \caption{B}\label{B}
+ \setkeys{draftfigure}{content={another white box}}
+ \includegraphics[draft]{example-image-c}
+ \caption{C}\label{C}
+\end{figure}
+\end{codeexample}
+You probably noticed that I defined some text within |content| for \cref{A}.
+This text is also shown for \cref{B} although I didn’t define it again --
+the options you define with |\setkeys{draftfigure}|\marg{options}
+are valid (in an environment) until they are refined
+as this happens for \cref{C}.
+
+The same effect you see with the option |filename| which is enabled for \cref{B} and still valid for \cref{C}.
+
+On the next page I show how to deactivate certain options.
+\clearpage
+\begin{codeexample}
+\begin{figure}[H]
+ \centering
+ \setkeys{draftfigure}{content={white box}}
+ \includegraphics[draft]{example-image-a}
+ \caption{A}\label{A1}
+
+ \setkeys{draftfigure}{filename=true,
+ style={tt},position={right}}
+ \includegraphics[draft]{example-image-b}
+ \caption{B}\label{B1}
+
+ \setkeys{draftfigure}{content={hidden image},
+ style={rm},filename=false,position={center}}
+ \includegraphics[draft]{example-image-c}
+ \caption{C}\label{C1}
+\end{figure}
+\end{codeexample}
+%Now you can see that for \cref{C1} I set |filename=false| so it isn’t shown in the white box.
+
+\clearpage
+\section{Things to work on}
+There are still things which work not satisfactually:
+\begin{itemize}
+ \item noframe for individual image
+\item combine different styles: sc and sf etc.
+\item color frame
+\item image instead of text in background
+\end{itemize}
+If anyone has some ideas please let me know: \href{mailto:lukas@digitales-altertum.de}{lukas@digitales-altertum.de}
+
+\section{Changelog}
+\PrintRevisions
+
+\end{document} \ No newline at end of file