summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/dlfltxb/dlfltxbmisc.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 /macros/latex/contrib/dlfltxb/dlfltxbmisc.sty
Initial commit
Diffstat (limited to 'macros/latex/contrib/dlfltxb/dlfltxbmisc.sty')
-rw-r--r--macros/latex/contrib/dlfltxb/dlfltxbmisc.sty162
1 files changed, 162 insertions, 0 deletions
diff --git a/macros/latex/contrib/dlfltxb/dlfltxbmisc.sty b/macros/latex/contrib/dlfltxb/dlfltxbmisc.sty
new file mode 100644
index 0000000000..5788d06adb
--- /dev/null
+++ b/macros/latex/contrib/dlfltxb/dlfltxbmisc.sty
@@ -0,0 +1,162 @@
+\ProvidesPackage{dlfltxbmisc}[2010/03/04 v0.3 by Lars Madsen]
+
+% This package 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.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Lars Madsen (daleif@imf.au.dk).
+%%
+
+
+
+% if memoir is not loaded we will need the chngpage to get adjustwidth
+\@ifclassloaded{memoir}{}{
+ \RequirePackage{chngpage}
+}
+
+\RequirePackage{ragged2e}
+\RequirePackage{url}
+\RequirePackage{calc}
+
+\@ifundefined{marg}{\newcommand\marg{}}{}
+\@ifundefined{oarg}{\newcommand\oarg{}}{}
+\@ifundefined{parg}{\newcommand\parg{}}{}
+
+
+\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{\}}}%
+}
+\renewcommand*\marg{\@ifstar{\marg@s}{\marg@n}}
+
+\newcommand*\oarg@s[1]{\textnormal{\texttt{[#1]}}}
+\newcommand*\oarg@n[1]{%
+ \textnormal{\texttt{[}$\langle$\textit{#1}$\rangle$\texttt{]}}%
+}
+\renewcommand*\oarg{\@ifstar{\oarg@s}{\oarg@n}}
+
+\newcommand*\parg@s[1]{\textnormal{\texttt{(#1)}}}
+\newcommand*\parg@n[1]{%
+ \textnormal{\texttt{(}$\langle$\textit{#1}$\rangle$\texttt{)}}%
+}
+\renewcommand*\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\o 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][\textsf{URL}:]{%
+ \getlastlinesize{}%
+ \vskip-2\baselineskip%
+ \begingroup%
+ \urlstyle{sf}
+ \def\UrlNoBreaks{\do\(\do\[\do\{\do\<\do\:\do\.}%\]
+ \RaggedLeft%
+ \fussy%
+ \hbadness=10000% cheating
+ \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 .7em
+ \fi%
+ {\footnotesize #1~~{\url{#2}}} %
+ \par%
+ \endgroup%
+}
+
+\AtBeginDocument{\providecommand\href[2]{#2}}
+
+\DeclareUrlCommand\mypath{\urlstyle{sf}}
+%\urlstyle{rm}
+\newcommand\addCTAN[3][\textsf{CTAN}:]{%
+ \getlastlinesize{}%
+ \vskip-2\baselineskip%
+ \begingroup%
+% \urlstyle{rm}
+ \def\UrlNoBreaks{\do\(\do\[\do\{\do\<\do\:\do\.}%\]
+ \RaggedLeft%
+ \fussy%
+ \hbadness=10000% cheating
+ \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 .7em
+ \fi%
+ {\footnotesize
+ \href{http://mirror.ctan.org/#2}{#1~~{\mypath{#2}}}} %
+ \par%
+ \endgroup%
+}
+
+\newcommand\CTAN[1]{%
+ {\footnotesize\href{http://mirror.ctan.org/#1}{\textsf{CTAN:}~{\mypath{#1}}}}}