%\iffalse % MetaComment
%%
%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
%% |            Copyright(C) 1997-2010 by F. Bosisio             |
%% |                                                             |
%% | This program can be redistributed and/or modified under	 |
%% | the terms 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 LaTeX distributions |
%% | version 2005/12/01 or later.                                |
%% |                                                             |
%% | This work has the LPPL maintenance status `maintained'.     |
%% | The Current Maintainer of this work is F. Bosisio.          |
%% |                                                             |
%% | This work consists of files sobolev.dtx and sobolev.html    |
%% | and of the derived files sobolev.sty and sobolev.pdf.       |
%% |                                                             |
%% | E-mail:   fbosisio@bigfoot.com                              |
%% | CTAN location: macros/latex/contrib/bosisio/                |
%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
%%
%%	If you make any improvment, find any bug or have
%%	any suggestion, please let me know about it.
%%
%<*package,driver>
%\fi
%
\def\FileName{sobolev}
%\iffalse % MetaComment
%</package,driver>
%<*package>
%\fi
\def\fileversion{2.2}
\def\filedate{1997/11/14}
\def\docdate{2005/04/09}
\def\filedescr{Commands to print the Sobolev spaces (FB)}
%
%\iffalse % MetaComment
%</package>
%<*dtx>
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%		This section is the installation driver
%
\def\batchfile{\FileName.dtx}
%
\input docstrip
%
\keepsilent
% \askforoverwritefalse
%
\generateFile{\FileName.sty}{f}{\from{\FileName.dtx}{package}}
%
\generateFile{\FileName.drv}{f}{\from{\FileName.dtx}{driver}}
%
\Msg{******************************************************}
\Msg{*}
\Msg{* To produce the documentation run the}
\Msg{* file `\FileName.drv' through LaTeX.}
\Msg{*}
\Msg{******************************************************}
%
\endbatchfile
%
%		End of the installation driver
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%</dtx>
%
%		This section is the documentation driver
%
%<+driver>\documentclass[12pt,a4paper]{ltxdoc}
%<+driver>  \EnableCrossrefs
%<+driver>  \CodelineIndex
%<+driver>  \RecordChanges
%<+driver>  %\OnlyDescription   % Uncomment not to see the implementation
%<+driver>\begin{document}
%<+driver>  \DocInput{\FileName.dtx}
%<+driver>  \PrintIndex
%<+driver>  \PrintChanges
%<+driver>\end{document}
%
%		End of the documentation driver
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%<*package>
%\fi
%
% \changes{v0.1}{28 March 1997}{First release (basic commands)}
% \changes{v0.2}{3 April 1997}{Added package options}
% \changes{v0.3}{7 July 1997}{Fixed a bug in the command ``Scalar''}
% \changes{v0.4}{4 August 1997}{Fixed a bug in the options}
% \changes{v1.0}{5 August 1997}{Documentation added}
% \changes{v1.1}{4 November 1997}{Fixed a bug in the ``Hdiv'' command}
% \changes{v1.2}{5 November 1997}{Superscripts for ``Norm'' and ``SemiNorm''}
% \changes{v2.0}{14 November 1997}{Changed ``Scalar'' sintax; added ``Crochet''}
% \changes{v2.1}{5 March 1999}{Added copyright notice and changed addresses}
% \changes{v2.2}{9 April 2005}{Usage of the double-quote character (") avoided}
%
% \MakeShortVerb{\|}
%
% \title{Package \texttt{\FileName}\thanks{This is version \fileversion,
% last revised \filedate; documentation date \docdate}}
% \author{F. Bosisio\\\normalsize E-mail: \texttt{fbosisio@bigfoot.com}}
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
%	Documentation for the package \texttt{\FileName}.
% \end{abstract}
%
% \section{Introduction}
%	This package provides some commands which are useful when dealing
%	with Sobolev spaces and their relatives.
%
%	In particular some commands are redefined, so care should be
%	taken, expecially when including this package in an already
%	existent \LaTeX{} file.
%
%	\noindent
%	The redefined commands are |\H| and |\L|.
%	The effect of ``|\H|'' (which is a type of accent) can now be
%	achieved by the command ``|\HAccent|'', whilst the job of ``|\L|''
%	(i.e. print an ``L'' with a superimposed bar) is now done by the
%	command ``|\Lbar|''.
%
% \section{The options}
%	Two options are available at the moment: \texttt{DivInBrackets}
%	and \texttt{DivAsExponent}.
%	They only affect the output of the ``|\Hdiv|'' command.
%
%	\noindent
%	The firt options (\texttt{DivInBrackets}, which is the default)
%	makes |\Hdiv| behave like ``|H(div;|\dots|)|'', while the second
%	one (\texttt{DivAsExponent}) makes |\Hdiv| expand to
%	``|H^{div}(|\dots|)|''.
%
% \section{The commands}
%	Most of the subsequent space-generating commands have mandatory
%	arguments to indicate the type of the space.
%	Often this argument consists of a single digit: in this case it
%	is \emph{not} necessary to enclose it in brackets, since in \LaTeX{}
%	the names of commands consists of letters only, and so a digit
%	following it is certainly an argument.
%	This saves a lot of typing and is the only reason that makes these
%	commans useful (if you always had to type the brackets, then it
%	would have been simpler to type the expansion of the command than
%	the command itself !).
%	In other words, you can think as if several commands exist (like
%	|\H|, |\H1|, |\H10|, etc.), the ones with the digit beeing a sort of
%	abbreviation for the general one.
%
%	\subsection{The \texttt{H} command}
%		The |\H| command is used to generate the symbol of sobolev
%		spaces.
%		It takes a mandatory argument, which is used as a
%		superscript, and an optional argument, which is used as a
%		subscript.
%
%		\noindent
%		As explained above, if the mandatory argument is a digit,
%		it need not be enclosed in brackets.
%		Moreover, if the optional argument is the digit ``0'', it
%		can be typed without the square brackets.
%
%		\noindent
%		Here are some examples (whith the |\DefaultSet| set to its
%		default value |\Omega|):
%
%		\begin{tabular}{lll}
%			|\H2|		& $\Longrightarrow$ & $H^2(\Omega)$	       \\
%			|\H10|		& $\Longrightarrow$ & $H^1_0(\Omega)$	       \\
%			|\H1[\Gamma_D]|	& $\Longrightarrow$ & $H^1_{\Gamma_D}(\Omega)$ \\
%			|\H{-1/2}|	& $\Longrightarrow$ & $H^{-1/2}(\Omega)$
%		\end{tabular}
%
%	\subsection{The \texttt{Hdiv} command}
%		The |\Hdiv| command is used to generate the sobolev space
%		called ``H div''.
%		It takes only an optional argument, which is used as a
%		subscript and which need not to be surrounded by the square
%		brackets if it is the digit ``0''.
%
%		\noindent
%		If the (default) option \texttt{DivInBrackets} is in effect,
%		it differs from the command |\H| in that the word ``div'' is
%		printed (in roman type) inside brackets, before the set.
%		If, instead, the option \texttt{DivAsExponent} is active,
%		then it is simply an abbreviation for |\H{\mathrm{div}}|.
%
%		\noindent
%		Here are some examples:\\
%		\hfill \begin{tabular}{llcc}
%					   &		       & |DivInBrackets|		     & |DivAsExponent|	\\
%			|\Hdiv|		   & $\Longrightarrow$ & $H(\mathrm{div};\Omega)$	     & $H^{\mathrm{div}}(\Omega)$	\\
%			|\Hdiv0|	   & $\Longrightarrow$ & $H_0(\mathrm{div};\Omega)$	     & $H^{\mathrm{div}}_0(\Omega)$	\\
%			|\Hdiv[\Gamma_D]|  & $\Longrightarrow$ & $H_{\Gamma_D}(\mathrm{div};\Omega)$ & $H^{\mathrm{div}}_{\Gamma_D}(\Omega)$
%		\end{tabular} \hfill
%
%	\subsection{The \texttt{L} command}
%		The |\L| command is used to generate the symbol of
%		Lebesgue-measurable functions.
%		It has one argument which is the exponent of the L-space.
%		Again, if this argument is a digit (or a single symbol,
%		like ``|\infty|'') the surrounding braces are optional.
%		Like for the |\H| command, the output of |\DefaultSet| is
%		appended.
%
%		\noindent
%		Here are some examples: \hspace{2cm}
%		\begin{tabular}{lll}
%			|\L2|		& $\Longrightarrow$ & $L^2(\Omega)$	       \\
%			|\L{10}|	& $\Longrightarrow$ & $L^{10}(\Omega)$	       \\
%			|\L\infty|	& $\Longrightarrow$ & $L^\infty(\Omega)$
%		\end{tabular}
%
%	\subsection{The \texttt{W} command}
%		The |\W| command is completly analogous, except that it
%		prints a ``W'' insted af an ``L'' and that it has two
%		argument, both printed as a supercript, separated by a comma.
%		It is used for the generalized Sobolev spaces.
%
%		\noindent
%		Here is an example of how it is used: \hspace{1cm}
%		\begin{tabular}{lll}
%			|\W{k}{p}|	& $\Longrightarrow$ & $W^{k,p}(\Omega)$ \\
%			|\W1\infty|	& $\Longrightarrow$ & $W^{1,\infty}(\Omega)$
%		\end{tabular}
%
%	\subsection{The \texttt{D} command}
%		The |\D| command is used in the theory of distributions:
%		it prints the space of distributions over the |\DefaultSet|
%		if followed by a prime symbol, or its dual space, otherwise.
%		\hfill \begin{tabular}{lll}
%			|\D|	& $\Longrightarrow$ & $\mathcal{D}(\Omega)$ \\
%			|\D'|	& $\Longrightarrow$ & $\mathcal{D}'(\Omega)$
%		\end{tabular} \hfill
%
%	\subsection{The \texttt{Norm} command}
%		The |\Norm| command has a mandatory and an optional argument;
%		it generates the norm of the mandatory argument, with the
%		optional argument, if present, as a whole subscript, to
%		denote the space within which the norm is taken.
%
%		\noindent
%		Some examples: \hspace{3cm}
%		\begin{tabular}{lll}
%			|\Norm{f(x)}|	& $\Longrightarrow$ & $\left\|f(x)\right\|$ \\
%			|\Norm{g}[L^2]|	& $\Longrightarrow$ & $\left\|g\right\|_{L^2}$
%		\end{tabular}
%
%	\subsection{The \texttt{SemiNorm} command}
%		The |\SemiNorm| command is completly analoguos, but
%		generates the semi-norm instead of the norm.
%
%		\noindent
%		Some examples: \hspace{2cm}
%		\DeleteShortVerb{\|}
%		\MakeShortVerb{\!}
%		\begin{tabular}{lll}
%			!\SemiNorm{f(x)}!	& $\Longrightarrow$ & $\left|f(x)\right|$ \\
%			!\SemiNorm{g}[H^1]!	& $\Longrightarrow$ & $\left|g\right|_{H^1}$
%		\end{tabular}
%		\DeleteShortVerb{\!}
%		\MakeShortVerb{\|}
%
%	\subsection{The \texttt{Scalar} command}
%		The |\Scalar| command has two arguments; a third optional
%		argument (which is used as a whole subscript) may follow
%		inside square brackets.
%		The output consists of the two arguments separated by a
%		comma and enclosed in a pair of adjustable-size brackets,
%		with the optional argument placed as a subscript (to denote
%		the space inside which the scalr product is taken).
%
%		\noindent
%		Some examples:
%		\begin{tabular}{lll}
%			|\Scalar{f}{g}|	     &$\Longrightarrow$& $\left(f,g\right)$ \\
%			|\Scalar{u}{v}[L^2]| &$\Longrightarrow$& $\left(u,v\right)_{L^2}$\\
%		\end{tabular}
%
%	\subsection{The \texttt{Crochet} command}
%		The |\Crochet| command has two arguments; a third optional
%		argument (which is used as a whole subscript) may follow
%		inside square brackets.
%		The output consists of the two arguments separated by a
%		comma and enclosed in a pair of adjustable-size
%		angular-parenthesys, with the optional argument placed as
%		a subscript (to denote the space inside which the duality
%		is taken).
%
%		\noindent
%		Some examples:
%		\begin{tabular}{lll}
%			|\Crochet{f}{g}|    &$\Longrightarrow$& $\left\langle f,g\right\rangle$ \\
%			|\Crochet{u}{v}[D]| &$\Longrightarrow$& $\left\langle u,v\right\rangle_D$\\
%		\end{tabular}
%
% \StopEventually{}
% \newpage
% \section{Implementation}
%
%    \begin{macrocode}
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{\FileName}[\filedate\space v\fileversion\space\filedescr]
%    \end{macrocode}
%
%	The options set the flag for the |\Hdiv| command.
%    \begin{macrocode}
%%
\newif\if@DivAsExp
\DeclareOption{DivAsExponent}{\@DivAsExptrue}
\DeclareOption{DivInBrackets}{\@DivAsExpfalse}
%%
\ExecuteOptions{DivInBrackets}
%    \end{macrocode}
%
%    The ``|\ProcessOptions*|'' command was used here instead of
%    ``|\ProcessOptions*|'' in order to process the options in the
%    ``|\usepackage|'' order, rather than in the declaration order
%    \begin{macrocode}
%%
\ProcessOptions*
%    \end{macrocode}
%
% \begin{macro}{\DefaultSet}
%	The command |\DefaultSet| makes |\@DefaultSet| to print the
%	given argument enclosed in brackets.
%	It also let |\@DefaultSet@Div| to be the same, but with the
%	word ``div'' inside the brackets, before the argument.
%    \begin{macrocode}
%%
\newcommand{\DefaultSet}[1]{\def\@DefaultSet{(#1)}%
			    \def\@DefaultSet@Div{(\mathrm{div};#1)}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NoDefaultSet}
%	The command |\NoDefaultSet| deletes the content of the two macros
%	|\@DefaultSet| and |\@DefaultSet@Div|, so that the first prints
%	nothing, whilst the second only prints ``(div)''.
%    \begin{macrocode}
\newcommand{\NoDefaultSet}{\let\@DefaultSet=\relax%
			   \def\@DefaultSet@Div{(\mathrm{div})}}
%    \end{macrocode}
%
%	\noindent
%	Set the default value for |\DefualtSet| to be $\Omega$.
%    \begin{macrocode}
%%
\DefaultSet{\Omega}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DoNothing@zero}
%	This command does nothing, but strips the character ``0'' (which
%	\emph{must} immediately follow it, otherwise an error occour)
%	from the input, since it is defined with a ``0'' attached to its
%	name.
%    \begin{macrocode}
%%
\def\DoNothing@zero0{\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\H}
%	The commands ``|\@HSobolev|< and``|\HSobolev@quadra|'' prints
%	an ``H'' in math-mode (via the |\ensuremath| command) with the
%	argument as a superscript, and, respectively, without subscripts
%	and wiht the second argument as a subscript.
%	Then they call |\@DefaultSet| in order to print the name of a set
%	inside brackets, or nothing depending on which of the commands
%	|\DefaultSet| and |\NoDefaultSet| has previously been invoked.
%    \begin{macrocode}
%%
\newcommand{\@HSobolev}[1]{\ensuremath{H^{#1}\@DefaultSet}}
\def\HSobolev@quadra#1[#2]{\ensuremath{H^{#1}_{#2}\@DefaultSet}}
%    \end{macrocode}
%	The original command ``|\H|'' (used to make a type of accent) is
%	saved in |\HAccent|; then |\H| is redefined so that it calls one
%	of the previous two commands, depending on which character
%	follows the command name.
%	If this character is a ``0'', then it also invokes the command
%	|\DoNothing@zero|, in order to strip that zero from the input.
%	All this is deferred at the ``|\begin{document}|'' in order to
%	avoid conflicts with other packages.
%    \begin{macrocode}
\AtBeginDocument{%
\let\HAccent=\H
\renewcommand{\H}[1]{%
\@ifnextchar0{\HSobolev@quadra{#1}[0]\DoNothing@zero}{%
\@ifnextchar[{\HSobolev@quadra{#1}}{\@HSobolev{#1}}}%
}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Hdiv}
%	The command |\@Hdiv@quadra| is used if the command |\Hdiv| is
%	followed by a square bracket: it simply types ``H'' (in math mode)
%	with a subscript.
%	It also prints ``div'' (in roman) as an exponent and calls
%	|\@DefaultSet| (with the ``DivAsExponent'' option) or calls
%	|\@DefaultSet@Div| (with the ``DivInBraces'' option).
%    \begin{macrocode}
%%
\def\@Hdiv@quadra[#1]{%
\if@DivAsExp \ensuremath{H^{\mathrm{div}}_{#1}\@DefaultSet}%
\else \ensuremath{H_{#1}\@DefaultSet@Div}\fi%
}
%    \end{macrocode}
%	The ``|\Hdiv|< command is defined so that it calls the previous command,
%	or typesets the output itself, similarly to the |\H| command above.
%    \begin{macrocode}
\newcommand{\Hdiv}{%
\@ifnextchar0{\@Hdiv@quadra[0]\DoNothing@zero}{\@ifnextchar[{\@Hdiv@quadra}{%
\if@DivAsExp \ensuremath{H^{\mathrm{div}}\@DefaultSet}%
\else \ensuremath{H\@DefaultSet@Div}\fi}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\L}
%	First the old command |\L| (which prints an ``L'' whith a bar
%	superimposed) is saved in |\Lbar|.
%	Then |\L| is redefined to print an ``L'' in math-mode with its
%	argument as a superscript, followed by the output of |\@DefaultSet|.
%	All this is deferred at the ``|\begin{document}|'' in order to
%	avoid conflicts with other packages.
%    \begin{macrocode}
%%
\AtBeginDocument{%
\let\Lbar=\L
\renewcommand{\L}[1]{\ensuremath{L^{#1}\@DefaultSet}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\W}
%	The command |\W| is defined to print a ``W'' in math-mode with its
%	two arguments as a superscript (separated by a comma) and followed
%	by the output of |\@DefaultSet|.
%	It is deferred at the ``|\begin{document}|'' in order to
%	avoid conflicts with other packages.
%    \begin{macrocode}
%%
\AtBeginDocument{%
\newcommand\W[2]{\ensuremath{W^{#1,#2}\@DefaultSet}}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\D}
%	The command |\D| is defined to print a calligraphic ``D'' in
%	math-mode, followed by the output of |\@DefaultSet|.
%	In order to allow for the proper treatment of the \emph{prime}
%	symbol which can follow the command, the command |\InsiemeD@Primo|
%	is defined: it is authomatically invoked by the command |\D| when
%	followed by a prime. It differs only in that a prime is output
%	\emph{before} invoking |\@DefaultSet|.
%	This is deferred at the ``|\begin{document}|'' in order to
%	avoid conflicts with other packages.
%    \begin{macrocode}
%%
\def\InsiemeD@Primo'{\ensuremath{\mathcal{D}'\@DefaultSet}}
\AtBeginDocument{%
\newcommand{\D}{\@ifnextchar'{\InsiemeD@Primo}{%
\ensuremath{\mathcal{D}\@DefaultSet}}%
}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Norm}
%	The command |\Norm| prints its argument surrounded by a
%	double-pipe delimiter of adjustable size.
%	If an optional argument is present, it is used as a whole subscript.
%    \begin{macrocode}
%%
\def\@Norma@Exp#1#2^#3{\ensuremath{\left\|#1\right\|_{#2}^{#3}}}
\def\@Norma#1[#2]{%
\@ifnextchar^{\@Norma@Exp{#1}{#2}}{\ensuremath{\left\|#1\right\|_{#2}}}%
}
\newcommand{\Norm}[1]{%
\@ifnextchar[{\@Norma{#1}}{\ensuremath{\left\|#1\right\|}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SemiNorm}
%	The command |\SemiNorm| prints its argument surrounded by a
%	single-pipe delimiter of adjustable size.
%	If an optional argument is present, it is used as a whole subscript.
%    \begin{macrocode}
%%
\def\@SemiNorma@Exp#1#2^#3{\ensuremath{\left|#1\right|_{#2}^{#3}}}
\def\@SemiNorma#1[#2]{%
\@ifnextchar^{\@SemiNorma@Exp{#1}{#2}}{\ensuremath{\left|#1\right|_{#2}}}%
}
\newcommand{\SemiNorm}[1]{%
\@ifnextchar[{\@SemiNorma{#1}}{\ensuremath{\left|#1\right|}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Scalar}
%	The command |\Scalar| requires two arguments; a third optional
%	argument (which is used as a whole subscript) may follow inside
%	square brackets.
%	The output consists of the two arguments separated by a comma and
%	enclosed in a pair of adjustable-size brackets, with the optional
%	argument placed as a subscript.
%    \begin{macrocode}
%%
\def\@ProdottoScalare#1#2[#3]{\ensuremath{\left(#1,#2\right)_{#3}}}
\newcommand\Scalar[2]{%
\@ifnextchar[{\@ProdottoScalare{#1}{#2}}{\ensuremath{\left(#1,#2\right)}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Crochet}
%	The command |\Crochet| requires two arguments; a third optional
%	argument (which is used as a whole subscript) may follow inside
%	square brackets.
%	The output consists of the two arguments separated by a comma and
%	enclosed in a pair of adjustable-size angular-parenthesys, with
%	the optional argument placed as a subscript.
%    \begin{macrocode}
%%
\def\Inner@Crochet#1#2[#3]{\ensuremath{\left\langle#1,#2\right\rangle_{#3}}}
\newcommand\Crochet[2]{%
\@ifnextchar[{\Inner@Crochet{#1}{#2}}{%
\ensuremath{\left\langle#1,#2\right\rangle}}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \CheckSum{179}
% \Finale
%
\endinput