summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/image-gallery/image-gallery.cls
blob: 2f364b556e1a53aab584c92b19922f4ea66cb041 (plain)
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

% Rolf Niepraschk <Rolf.Niepraschk@ptb.de>
%
% This file 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 2003/12/01 or later.

%\errorcontextlines=100

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{image-gallery}[2007/08/27 v1.0h image gallery -- RN]
\DeclareOption{dummy}{%
  \AtEndOfClass{%
    \renewcommand*\IG@image[2][]{\rule{\IG@width}{\IG@height}}%
    \renewcommand*\IG@fillBox{%
      \textcolor{red}{\rule{\IG@width}{\IG@height}}}%
    \RequirePackage{color}%
  }%
}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass[10pt]{article}

\RequirePackage{graphicx,keyval,url}
\RequirePackage[margin={0mm,0mm},dvips]{geometry}
  
\newcommand*\IG@image[2][]{%
  \let\IG@tempa=\@empty
  \ifIG@autorotate
    \sbox\IG@box{\includegraphics[#1]{#2}}%
    \ifdim\wd\IG@box<\ht\IG@box
      \def\IG@tempa{angle=90,}%
    \fi
    \setbox\IG@box\box\voidb@x
  \fi
  \expandafter\includegraphics\expandafter[\IG@tempa#1]{#2}%
} 

\newcommand*\IG@fillBox{\mbox{\phantom{\rule{\IG@width}{\IG@height}}}}

\newlength\IG@width \newlength\IG@height
\newlength\IG@top \newlength\IG@bottom
\newlength\IG@left \newlength\IG@right
\newif\ifIG@more
\newcommand*\IG@rows{} \newcommand*\IG@columns{}
\newcommand*\IG@tempa{} \newcommand*\IG@imagefile{}
\newread\IG@input
\newsavebox\IG@box
\newif\ifIG@autorotate \IG@autorotatetrue

\define@key{IG}{width}{\setlength\IG@width{#1}}
\define@key{IG}{height}{\setlength\IG@height{#1}}
\define@key{IG}{top}{\setlength\IG@top{#1}}
\define@key{IG}{bottom}{\setlength\IG@bottom{#1}}
\define@key{IG}{left}{\setlength\IG@left{#1}}
\define@key{IG}{right}{\setlength\IG@right{#1}}
\define@key{IG}{rows}{\edef\IG@rows{\number#1}}
\define@key{IG}{columns}{\edef\IG@columns{\number#1}}
\define@key{IG}{autorotate}[true]{\csname IG@autorotate#1\endcsname}

\newcommand*\gallerySetup[1]{%
  \setkeys{IG}{#1}
  \geometry{left=\IG@left,right=\IG@right,top=\IG@top,bottom=\IG@bottom}
}

\newcommand*\makeGallery[1]{%
  \begingroup
    \immediate\openin\IG@input=#1\relax
    \IG@moretrue\@tempcnta=\z@\@tempcntb=\@ne
    \endlinechar=\m@ne
    \loop
      \ifeof\IG@input\IG@morefalse\else
        \read\IG@input to\IG@imagefile
        \if\IG@imagefile\par\else
          \ifx\IG@imagefile\@empty\else
            \advance\@tempcnta\@ne
            \makebox[\IG@width][c]{%
              \IG@image[width=\IG@width,height=\IG@height,keepaspectratio]%
                {\IG@imagefile}}%
            \makebox[0pt][c]{%
              \hskip-\IG@width\raisebox{-\ht\strutbox}[0pt][0pt]{%
                \expandafter\IG@showname\expandafter{\IG@imagefile}}}%
            \ifnum\@tempcnta=\IG@columns\relax
              \@tempcnta=\z@ \par
              \ifnum\@tempcntb=\IG@rows\relax
                \@tempcntb=\@ne \newpage
              \else
                \advance\@tempcntb\@ne \vfill
              \fi
            \else
              \hfill
            \fi
          \fi
        \fi
      \fi
    \ifIG@more\repeat
    \immediate\closeout\IG@input
    \IG@moretrue
    \ifnum\@tempcntb=\@ne\else
      \loop
        \advance\@tempcnta\@ne
        \IG@fillBox
        \ifnum\@tempcnta=\IG@columns\relax
          \@tempcnta=\z@ \par
          \ifnum\@tempcntb=\IG@rows\relax
            \@tempcntb=\@ne \IG@morefalse
          \else
            \advance\@tempcntb\@ne \vfill
          \fi
        \else
          \hfill
        \fi
      \ifIG@more\repeat
    \fi
  \endgroup
}

\parindent=\z@ \pagestyle{empty}
\DeclareUrlCommand\IG@showname{\urlstyle{same}}

\endinput