summaryrefslogtreecommitdiff
path: root/info/examples/ltt/sidefig.sty
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 /info/examples/ltt/sidefig.sty
Initial commit
Diffstat (limited to 'info/examples/ltt/sidefig.sty')
-rw-r--r--info/examples/ltt/sidefig.sty54
1 files changed, 54 insertions, 0 deletions
diff --git a/info/examples/ltt/sidefig.sty b/info/examples/ltt/sidefig.sty
new file mode 100644
index 0000000000..2b78814dc3
--- /dev/null
+++ b/info/examples/ltt/sidefig.sty
@@ -0,0 +1,54 @@
+% sidefig.sty
+\RequirePackage{ifthen}
+\RequirePackage{calc}
+
+\newsavebox{\figbox}
+\newlength{\leftnegwidth}
+\setlength{\leftnegwidth}
+ {\marginparwidth+\marginparsep}
+\newcommand{\@lab}{}
+\newcommand{\@cap}{}
+\newcommand{\@captp}{}
+
+% \begin{sidefig}[type]{caption}{label}
+% <figure> or <table>
+% \end{sidefig}
+\newenvironment{sidefig}[3][figure]
+ { \renewcommand{\@lab}{\pageref{#3}}
+ \renewcommand{\@captp}{#1}
+ \renewcommand{\@makecaption}[2]
+ {\raggedright\textbf{##1}\\##2}
+ \renewcommand{\@cap}{\caption{#2\label{#3}}}
+ \begin{lrbox}{\figbox}
+ \begin{minipage}{\textwidth}\centering
+ }
+ % schliessender Teil
+ { \end{minipage}\end{lrbox}
+ \@float{\@captp}
+ % Label schon im Hilfsfile?
+ \ifthenelse{\equal{\@lab}{}}
+ % nein, dann einfach Bild drucken
+ {\usebox{\figbox}}
+ % ja, dann gerade-ungerade-Test durchfuehren
+ {\ifthenelse{\isodd{\@lab}}
+ % ungerade Seite: Legende rechts
+ {\parbox{\textwidth+\leftnegwidth}
+ {\usebox{\figbox}
+ \hfil
+ \begin{minipage}[c]{\marginparwidth}
+ \@cap
+ \end{minipage}
+ }
+ }
+ % gerade Seite: Legende links
+ {\hspace*{-\leftnegwidth}%
+ \parbox{\textwidth+\leftnegwidth}
+ {\begin{minipage}[c]{\marginparwidth}
+ \@cap
+ \end{minipage}
+ \hfil
+ \usebox{\figbox}
+ }
+ }
+ }
+ \end@float}