From 46407651698b50506037411619e7076d12d39ce3 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 20 Jun 2014 18:22:26 +0000 Subject: ot-tableau (5jun14) git-svn-id: svn://tug.org/texlive/trunk@34340 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/ot-tableau/ot-tableau.sty | 132 ++++++++++++++++----- 1 file changed, 101 insertions(+), 31 deletions(-) (limited to 'Master/texmf-dist/tex/latex/ot-tableau') diff --git a/Master/texmf-dist/tex/latex/ot-tableau/ot-tableau.sty b/Master/texmf-dist/tex/latex/ot-tableau/ot-tableau.sty index 1d082ae13ca..063952ec2e0 100644 --- a/Master/texmf-dist/tex/latex/ot-tableau/ot-tableau.sty +++ b/Master/texmf-dist/tex/latex/ot-tableau/ot-tableau.sty @@ -1,61 +1,131 @@ -% Note that tableau requires arydshln, which must be loaded after longtable - -\ProvidesPackage{ot-tableau} - -\RequirePackage{tipa,ifthen,pifont,substr,bbding,suffix} +% Note that ot-tableau requires arydshln, which must be loaded after longtable +\ProvidesPackage[2014-06-04]{ot-tableau} + +% Package option: notipa +\newif\ifottableau@tipa +\DeclareOption{tipa}{\ottableau@tipatrue} +\DeclareOption{notipa}{\ottableau@tipafalse} + +% Package option: circledviolations +\newif\ifottableau@circledviolations +\DeclareOption{circledviolations}{\ottableau@circledviolationstrue} + +% Package option: shadedcells +\newif\ifottableau@shadedcells +\DeclareOption{shadedcells}{\ottableau@shadedcellstrue} + +% Package option: fingerafter +\newif\ifottableau@fingerfirst +\ottableau@fingerfirsttrue +\DeclareOption{fingerafter}{\ottableau@fingerfirstfalse} + +\ExecuteOptions{tipa} % default is tipa +\ProcessOptions\relax + +\RequirePackage{xstring} +\RequirePackage{amssymb} % provides the asterisks +\RequirePackage{bbding} % provides \HandRight, etc. +\RequirePackage{suffix} \RequirePackage{colortbl} \RequirePackage{arydshln} % IPA typesetting macros -\def\ipa#1{\textipa{#1}} -\def\ip#1{[\textipa{#1}]} -\def\ips#1{/\textipa{#1}/} +\def\ipa#1{#1} +\def\ip#1{[#1]} +\def\ips#1{/#1/} +\ifottableau@tipa + \RequirePackage{tipa} + % use TIPA for IPA commands: + \def\ipa#1{\textipa{#1}} + \def\ip#1{[\textipa{#1}]} + \def\ips#1{/\textipa{#1}/} +\fi + +% Control package options inline + +\def\TipaOn{\ottableau@tipatrue} +\def\TipaOff{\ottableau@tipafalse} + +\def\CircledViolationsOn{\ottableau@circledviolationstrue} +\def\CircledViolationsOff{\ottableau@circledviolationsfalse} + +\def\ShadingOn{\ottableau@shadedcellstrue} +\def\ShadingOff{\ottableau@shadedcellsfalse} + +\def\FingerBeforeLetter{\ottableau@fingerfirsttrue} +\def\LetterBeforeFinger{\ottableau@fingerfirstfalse} + + +% Custom Markers +\newcommand\OptimalMarker{\HandRight} +\newcommand\ViolationMarker{$\ast$} +\newcommand\CircledViolationMarker{$\circledast$} % OT tableaux \newcounter{tableaurow} -\newcolumntype{s}{>{\ShadeTheCell}c} +% Keep track of whether the optimal candidate is optimal +\newif\ifottableau@optimal +\def\OptimalOn{\globaldefs=1\ottableau@optimaltrue\globaldefs=0} +\def\OptimalOff{\globaldefs=1\ottableau@optimalfalse\globaldefs=0} +\newcommand{\Optimal}{\OptimalMarker\OptimalOn} +%%%%%%%%%%%%%%%%%%%%%%%%% +%% Cell shading commands -\def\ShadedCells{no} -\def\ShadingOn{\def\ShadedCells{yes}} -\def\ShadingOff{\def\ShadedCells{no}} +% Wholly shaded constraint columns must be specified with the s column type +\newcolumntype{s}{>{\ShadeTheCell}c} \def\CellShading{0.9} \def\SetCellShading#1{\def\CellShading{#1}} \def\ShadeTheCell{\cellcolor[gray]{\CellShading}} - \def\UnshadeTheCell{\cellcolor[gray]{1}} -\def\Excl{no} +\newif\ifottableau@excl +\def\ExclOff{\globaldefs=1\ottableau@exclfalse\globaldefs=0} +\def\ExclOn{\globaldefs=1\ottableau@excltrue\globaldefs=0} -\def\fingerfirst{yes} -\def\FingerBeforeLetter{\def\fingerfirst{yes}} -\def\LetterBeforeFinger{\def\fingerfirst{no}} \newcommand*{\rowletter}{\stepcounter{tableaurow}\alph{tableaurow}. } \newenvironment{tableau}[1]{\setcounter{tableaurow}{0}% \dashlinegap=2pt% - \ifthenelse{\equal{\fingerfirst}{yes}}% - {\begin{tabular}{|r@{\hspace{4pt}}l@{\hspace{3pt}}l||#1|}}%then - {\begin{tabular}{|l@{\hspace{2pt}}r@{\hspace{4pt}}l||#1|}}%else + \ifottableau@fingerfirst + \begin{tabular}{|r@{\hspace{4pt}}l@{\hspace{3pt}}l||#1|} + \else + \begin{tabular}{|l@{\hspace{2pt}}r@{\hspace{4pt}}l||#1|} + \fi% }{\\\hline\end{tabular}} \def\properlines{\ifthenelse{\thetableaurow=0}{\\\hline\hline}{\\\hline}} -\newcommand\cand[2][]{\properlines\ifthenelse{\equal{\fingerfirst}{yes}}{#1&\rowletter}{\rowletter}&\ipa{#2}\gdef\Excl{no}} -\WithSuffix\newcommand\cand*[2][]{\properlines\ifthenelse{\equal{\fingerfirst}{yes}}{#1&\rowletter}{\rowletter}\gdef\Excl{no}} - -\def\vio#1{\ifthenelse{\equal{\Excl}{yes}\and\equal{\ShadedCells}{yes}}{\ShadeTheCell}{}\ifthenelse{\equal{\Excl}{yes}}{}{\IfSubStringInString{!}{#1}{\gdef\Excl{yes}}{\gdef\Excl{no}}}} +\newcommand\cand[2][]{\OptimalOff\properlines% + \ifottableau@fingerfirst \ipa{#1} \else \rowletter \fi% + & + \ifottableau@fingerfirst \rowletter \else \ipa{#1} \fi% + & + \ipa{#2}\ExclOff} + +\WithSuffix\newcommand\cand*[2][]{\OptimalOff\properlines% + \ifottableau@fingerfirst #1 \else \rowletter \fi% + & + \ifottableau@fingerfirst \rowletter \else #1 \fi% + \ExclOff} + +\def\vio#1{&% + \ifottableau@circledviolations + \ifottableau@optimal + \StrSubstitute{#1}{*}{\CircledViolationMarker} + \else + \StrSubstitute{#1}{*}{\ViolationMarker} + \fi + \else + \StrSubstitute{#1}{*}{\ViolationMarker} + \fi + \ifottableau@excl \ifottableau@shadedcells \ShadeTheCell \fi \fi% + \ifottableau@excl \empty \else \IfSubStr{#1}{!}{\ExclOn}{\ExclOff} \fi% + } \newcommand\inp[1]{\hline\multicolumn{3}{|l||}{#1}} \newcommand\const[1]{&\textsc{#1}\UnshadeTheCell} \WithSuffix\newcommand\const*[1]{\UnshadeTheCell} - - -% \begin{tableau}{c:c} -% \inp{input} \constraint{One} \constraint{Two} -% \cand{input} \vio{*!} \vio{*} -% \optcand{inp\super hut} \vio{} \vio{*} -% \end{tableau} -- cgit v1.2.3