-
Notifications
You must be signed in to change notification settings - Fork 0
/
draftfiguretest.tex
181 lines (153 loc) · 5.3 KB
/
draftfiguretest.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
\documentclass[
%draft
]{article}
\usepackage{filecontents}
\begin{filecontents}{draftfigure.sty}
% 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/05/06}
\def\df@version{0.1}
\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{% NOT WORKING
\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
}
%% 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}\df@noframe
%https://tex.stackexchange.com/a/94596/98739
\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{}
\providecommand\df@position@center{\centering}
\providecommand\df@position@bottom{}
\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}
\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}%
{\mbox{~}\\[\baselineskip]}%
{}%
\expandafter\strip@prefix\meaning\@tempa}%
{}%
\end{minipage}}%
\endinput
\end{filecontents}
\usepackage[%
% style={normal},
%size={},
% position={bottom},
% allfiguresdraft,
content={Kein Bild},
%filename,
%noframe=false,
]{draftfigure}
\usepackage{libertine}
\begin{document}
\ifbool{df@noframe}{true}{false}%<--- nur zum Testen
\begin{figure}
\setdf{
content={},filename}
% \setdf{content={Copyright}}
\includegraphics[width=.7\textwidth,draft]{example-image-a}
\end{figure}
\ifbool{df@noframe}{true}{false}%<--- nur zum Testen
\begin{figure}
\setdf{
noframe,filename,
content={\ifbool{df@noframe}{true}{false}}}
\includegraphics[width=.7\textwidth]{example-image-b}
\end{figure}
%<--- nur zum Testen
\begin{figure}
\setdf{
position ={left},
content={Dieses Bild kann nicht angezeigt werden, da die Digitalrechte fehlen und anschließend kommt noch ganz viel Text hinterher, um die Höhe des Bildes zu testen. Ich hoffe dieser viele Text hilft und reicht}}
\includegraphics[width=.4\textwidth]{example-image-c}
\end{figure}
\ifbool{df@noframe}{true}{false}%<--- nur zum Testen
%\ifbool{df@force}{true}{false}%<--- nur zum Testen
\end{document}