summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/dlfltxb/dlfltxbmisc.sty
blob: 80878531cb244d9f3ae874407491600fee545d82 (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
\ProvidesPackage{dlfltxbmisc}[2007/05/15 v0.1 by Lars Madsen]

% if memoir is not loaded we will need the chngpage to get adjustwidth
\@ifclassloaded{memoir}{}{
  \RequirePackage{chngpage}
}

\RequirePackage{ragged2e}
\RequirePackage{url}
\RequirePackage{calc}

\newcommand*\Arg@s[1]{\textnormal{\texttt{#1}}}%
\newcommand*\Arg@n[1]{\textnormal{$\langle$\textit{#1}$\rangle$}}%
\newcommand*\Arg{\@ifstar{\Arg@s}{\Arg@n}}%

\newcommand*\marg@s[1]{\textnormal{\texttt{\{#1\}}}}
\newcommand*\marg@n[1]{%
  \textnormal{\texttt{\{}$\langle$\textit{#1}$\rangle$\texttt{\}}}%
}
\newcommand*\marg{\@ifstar{\marg@s}{\marg@n}}

\newcommand*\oarg@s[1]{\textnormal{\texttt{[#1]}}}
\newcommand*\oarg@n[1]{%
  \textnormal{\texttt{[}$\langle$\textit{#1}$\rangle$\texttt{]}}%
}
\newcommand*\oarg{\@ifstar{\oarg@s}{\oarg@n}}

\newcommand*\parg@s[1]{\textnormal{\texttt{(#1)}}}
\newcommand*\parg@n[1]{%
  \textnormal{\texttt{(}$\langle$\textit{#1}$\rangle$\texttt{)}}%
}
\newcommand*\parg{\@ifstar{\parg@s}{\parg@n}}

\newcommand\malign[2][2pt]{%
  \makebox[0pt][l]{\kern#1\smash{\rule[-1.5mm-#2\baselineskip]{0.01pt}{5mm+#2\baselineskip}}}%
}


\newenvironment{syntax}{%
  \vskip.5\baselineskip\allowbreak%
  \begin{adjustwidth}{\parindent}{0pt}
    \parindent=0pt%
    \obeylines%
    \let\\=\relax%
  }{%
  \end{adjustwidth}%
  \vskip.5\baselineskip%
}
\newenvironment{syntax*}{%
  \vskip.5\baselineskip%
  \begin{adjustwidth}{\parindent}{0pt}
    \parindent=0pt%
  }{%
  \end{adjustwidth}%
  \vskip.5\baselineskip%
}

\let\syntaks=\syntax
\let\endsyntaks=\endsyntax

% macro used in several math examples to show the structure. It acts
% like some text but only displays a box.
\newcommand\@dbx[1]{{\fboxsep=0pt\fboxrule=0.4pt\,\fbox{\phantom{\rule[-0.6mm]{#1}{3mm}}}\,}}
\newcommand\dbx[1][5mm]{\ifmmode\mathord{\@dbx{#1}}\else\@dbx{#1}\fi}


% powerfull macro by Morten Høgholm, this enables you to measure the
% length of the previous paragraf.
\newdimen\lastlinedim
\def\getlastlinesize{%
   \begingroup\frozen@everydisplay{}%
        $$
        \abovedisplayskip=\z@skip \abovedisplayshortskip=\z@skip
        \belowdisplayskip=\z@skip \belowdisplayshortskip=\z@skip
        \global\lastlinedim=\dimexpr\predisplaysize-2em\relax
        \halign{##\cr}%
        $$
        \mbox{}%
        \endgroup%
}

% this is a very special little macro to be used in the 'note' field
% of bibtex entries. It eats up the added '.' and typesets the main
% argument (an URL) in a raggedright manner, wrapped up into the
% previous paragraph. It looks pretty cool.
\newcommand\addurl[3][\textsc{url}:]{%
  \getlastlinesize{}%
  \vskip-2\baselineskip%
  \begingroup%
  \def\UrlNoBreaks{\do\(\do\[\do\{\do\<\do\:\do\.}%\]
  \RaggedLeft%
  \fussy%
  \addtolength\lastlinedim{-\bibhang}%
  \fboxsep=0pt%
  \fboxrule=0pt%
  \fbox{\hbox to \lastlinedim{\hfill \footnotesize \strut   \hfill}}%
  \ifdim \lastlinedim > 0.6\linewidth\relax% we break
  \nopagebreak\vskip-3pt%
  \else%
  % special thanks to Dan Luecking for this, since my original
  % \hspace{\fill} failed miserably
  \hskip1em plus 5em minus .5em
  \fi%
  {\footnotesize #1~~{\url{#2}}} % 
  \par%
  \endgroup%
}