% \title{Linear Logic symbols for Computer Modern}
% \author{Emmanuel Beffara}
% \date{February 22, 2006}
%
% \maketitle
%
% \section{Documentation}
%
% \subsection{Installation}
%
% The installation consists in copying the |.mf| files from the |mf|
% subdirectory somewhere in Metafont's search path and the |.sty| and |.fd|
% files from the |latex| subdirectory somewhere in \LaTeX's search path.
%
% Call |TEXMF| the base directory of your installation (on Unix this should be
% something like |/usr/share/texmf| or |~/texmf| for a single user
% installation). Then copy the directories as follows:
% \begin{itemize}
%   \item copy |mf| as |TEXMF/fonts/source/public/cmll|
%   \item copy |latex| as |TEXMF/tex/latex/cmll|
% \end{itemize}
% If you want to install the fonts in Type1 format:
% \begin{itemize}
%   \item copy |type1| as |TEXMF/fonts/type1/public/cmll|
%   \item copy |tfm| as |TEXMF/fonts/tfm/public/cmll|
%   \item copy |cmll.map| as |TEXMF/fonts/map/dvips/misc/cmll.map|
% \end{itemize}
% You may have to update \TeX's databases by running |texhash| or |mktexlsr|
% (this is for Kpathsea-based distributions like te\TeX) or a similar command.
%
% \subsection{Package loading}
%
% The package is loaded by simply saying |\usepackage{cmll}|. The variant of
% the font that should be used is chosen using the following package options:
% \begin{quote}
%   \begin{tabular}{>{\ttfamily}ll}
%     cm & Computer Modern serif \\
%     ss & Computer Modern sans serif \\
%     euler & AMS Euler \\
%     auto & automatic selection (default)
%   \end{tabular}
% \end{quote}
% Automatic selection is done by looking at the loaded packages and the
% current font settings. Note that this works only when \texttt{cmll} is
% loaded \emph{after} changing those settings.
%
% \subsection{Symbols}
%
% The \texttt{cmll} font defines a handful of symbols useful in linear logic
% that were not defined in other fonts and packages.
% \begin{symbols}{Unary operators:}
% \dosymbol\oc \dosymbol\wn
% \dosymbol\shpos \dosymbol\shneg \dosymbol\shift
% \end{symbols}
% \begin{symbols}{Binary operators:}
% \dosymbol\parr \dosymbol\with
% \end{symbols}
% \begin{symbols}{Large operators:}
% \dosymbol\bigparr \dosymbol\bigwith
% \end{symbols}
% \begin{symbols}{Binary relations:}
% \dosymbol\coh \dosymbol\scoh
% \dosymbol\incoh \dosymbol\sincoh
% \end{symbols}
% The symbols $\oc$, $\wn$ and $\with$ are actually characters from the
% standard Computer Modern fonts declared with a new math code to get proper
% spacing. See the following examples:
% \[\begin{tabular}{ll@{\hspace{4em}}ll}
%   \verb/A \& B/ & $A \& B$ & \verb/A \with B/ & $A \with B$ \\
%   \verb/A = !B/ & $A = !B$ & \verb/A = \oc B/ & $A = \oc B$ \\
%   \verb/A = ?B/ & $A = ?B$ & \verb/A = \wn B/ & $A = \wn B$
% \end{tabular}\]
%
%
% \section{Files}
%
% \subsection{This document}
% 
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\usepackage{array,cmll}
\newenvironment{symbols}[1]{%
  \par%
  \def\dosymbol##1{\leavevmode\hbox to .5\textwidth{%
    \kern.25\textwidth \hbox to 2em{\hss$##1$\hfil}%
    \texttt{\string##1}\hss}\penalty10}%
  \flushleft%
  #1\strut\\}{\endflushleft}
\begin{document}
\DocInput{cmll.dtx}
\end{document}
%</driver>
%    \end{macrocode}
%
% \subsection{Font definitions}
%
% The font definition file is deduced from the ones for Computer Modern. We
% provide an NFSS entry named \texttt{cmllr} in medium and bold extended
% versions.
%
%    \begin{macrocode}
%<*ucmllr>
\DeclareFontShape{U}{cmllr}{m}{n}{%
      <5><6><7><8><9>gen*cmllr%
      <10->cmllr10}{}
\DeclareFontShape{U}{cmllr}{bx}{n}{%
      <5><6><7><8><9>gen*cmllbx%
      <10->cmllbx10}{}
%</ucmllr>
%    \end{macrocode}
%
% The following is a definition for the sans-serif version, named
% \texttt{cmllss}.
%
%    \begin{macrocode}
%<*ucmllss>
\DeclareFontShape{U}{cmllss}{m}{n}{%
      <-8>cmllss8%
      <9>cmllss9%
      <10->cmllss10}{}
\DeclareFontShape{U}{cmllss}{bx}{n}{%
      <->cmllssbx10}{}
%</ucmllss>
%    \end{macrocode}
%
% The following is a definition for the Euler-style version, named
% \texttt{eull}.
%
%    \begin{macrocode}
%<*ueull>
\DeclareFontShape{U}{eull}{m}{n}{%
      <5><6><7><8><9>gen*eullr%
      <10->eullr10}{}
\DeclareFontShape{U}{eull}{bx}{n}{%
      <5><6><7><8><9>gen*eullbx%
      <10->eullbx10}{}
%</ueull>
%    \end{macrocode}
%
% \subsection{The package}
%
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cmll}[2006/02/22 Linear Logic symbols for Computer Modern]
%    \end{macrocode}
%
% The font is declared as a symbol font named \texttt{llsymbols}, in normal
% and bold versions. We provide package options to switch between the
% standard, sans-serif and Euler-style variants.
%
%    \begin{macrocode}
\def\cmll@style{auto}
\DeclareOption*{\edef\cmll@style{\CurrentOption}}
\ProcessOptions\relax
%    \end{macrocode}
%
% The following code is used to detect which family should be used. Euler is
% detected if its package is loaded, sans-serif is detected by looking at the
% default font family name.
%    \begin{macrocode}
\RequirePackage{ifthen}
\def\cmll@use@auto{%
  \@ifpackageloaded{euler}{%
    \def\cmll@style{euler}}{%
    \ifthenelse{\equal{\rmdefault}{cmss}}{%
      \def\cmll@style{ss}}{%
      \def\cmll@style{cm}}}%
  \csname cmll@use@\cmll@style\endcsname}
%    \end{macrocode}
%
% The following macros are used to set up the font families and symbols from
% other fonts.
%    \begin{macrocode}
\def\cmll@use@cm{%
  \DeclareSymbolFont{llsymbols}{U}{cmllr}{m}{n}%
  \SetSymbolFont{llsymbols}{bold}{U}{cmllr}{bx}{n}%
  \DeclareMathSymbol{\with}{\mathbin}{operators}{`\&}%
  \DeclareMathSymbol{\oc}{\mathord}{operators}{`!}%
  \DeclareMathSymbol{\wn}{\mathord}{operators}{`?}}
%    \end{macrocode}
% Here is the sans-serif variant.
%    \begin{macrocode}
\def\cmll@use@ss{%
  \DeclareSymbolFont{llsymbols}{U}{cmllss}{m}{n}%
  \SetSymbolFont{llsymbols}{bold}{U}{cmllss}{bx}{n}%
  \DeclareMathSymbol{\with}{\mathbin}{operators}{`\&}%
  \DeclareMathSymbol{\oc}{\mathord}{operators}{`!}%
  \DeclareMathSymbol{\wn}{\mathord}{operators}{`?}}
%    \end{macrocode}
% And here is the Euler variant.
%    \begin{macrocode}
\def\cmll@use@euler{%
  \DeclareSymbolFont{llsymbols}{U}{eull}{m}{n}%
  \SetSymbolFont{llsymbols}{bold}{U}{eull}{bx}{n}%
  \DeclareMathSymbol{\with}{\mathbin}{EulerFraktur}{"26}%
  \DeclareMathSymbol{\oc}{\mathord}{EulerFraktur}{"21}%
  \DeclareMathSymbol{\wn}{\mathord}{EulerFraktur}{"3F}}
%    \end{macrocode}
% Finally we activate the proper variant.
%    \begin{macrocode}
\csname cmll@use@\cmll@style\endcsname
%    \end{macrocode}
%
% The new symbol definitions are the same for all variants.
%    \begin{macrocode}
\DeclareMathSymbol{\parr}{\mathbin}{llsymbols}{0}
\DeclareMathSymbol{\shpos}{\mathord}{llsymbols}{1}
\DeclareMathSymbol{\shneg}{\mathord}{llsymbols}{2}
\DeclareMathSymbol{\shift}{\mathord}{llsymbols}{3}
\DeclareMathSymbol{\coh}{\mathrel}{llsymbols}{4}
\DeclareMathSymbol{\scoh}{\mathrel}{llsymbols}{5}
\DeclareMathSymbol{\incoh}{\mathrel}{llsymbols}{6}
\DeclareMathSymbol{\sincoh}{\mathrel}{llsymbols}{7}
\DeclareMathSymbol{\bigwith}{\mathop}{llsymbols}{8}
\DeclareMathSymbol{\bigparr}{\mathop}{llsymbols}{10}
%</package>
%    \end{macrocode}
%
% \Finale
