summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-06-29 21:31:09 +0000
committerKarl Berry <karl@freefriends.org>2020-06-29 21:31:09 +0000
commit1791aa9d671806e0494f2d8d0323999c67909fb5 (patch)
treec7a22b24a5c3084ade55e1a0d8f1ab5579316cff /Master/texmf-dist/tex
parent37ddebe0f5b05bd81e2a4d2e27051d2ef3fbfc1d (diff)
langsci-avm (29jun20)
git-svn-id: svn://tug.org/texlive/trunk@55699 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty151
1 files changed, 118 insertions, 33 deletions
diff --git a/Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty b/Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty
index 9f3b1d07634..a5249d69619 100644
--- a/Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty
+++ b/Master/texmf-dist/tex/latex/langsci-avm/langsci-avm.sty
@@ -7,15 +7,23 @@
%% langsci-avm.dtx (with options: `package')
%% ------------------------------------------------------------------------------
%%
-%% langsci-avm: Attribute-value matrices (AVMs) and feature structures in LaTeX3.
+%% langsci-avm is aimed at typesetting beautiful feature structures,
+%% also known as attribute-value matrices (AVMs), for use in linguistics.
+%%
+%% The package provides a minimal and easy to read syntax.
+%% It depends only on the array package and can be placed almost everywhere,
+%% in particular in footnotes or graphs and tree structures. The package is meant
+%% as an update to, and serves the same purpose as, Christopher Manning’s
+%% avm package, but shares no code base with that package.
+%%
+%% langsci-avm was developed at Language Science Press to help in the
+%% production of scientific texts in linguistics.
%%
%% Copyright (C) 2020 by Felix Kopecky, Language Science Press
%%
-%% This work consists of the file langsci-avm.dtx &
-%% include/smallcaps-standalone.pdf.
+%% This work consists of the file langsci-avm.dtx
%% and the derived files langsci-avm.ins,
-%% langsci-avm.pdf,
-%% langsci-avm.sty.
+%% langsci-avm.pdf.
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -25,7 +33,7 @@
%% This work is ``maintained'' (per LPPL maintenance status) by
%% Felix Kopecky <felix.kopecky@langsci-press.org>.
%%
-%% The development version of the bundle can be found at
+%% The development version can be found at
%%
%% https://github.com/langsci/langsci-avm
%%
@@ -38,12 +46,14 @@
%% ------------------------------------------------------------------------------
\RequirePackage{xparse,array}
\ProvidesExplPackage {langsci-avm}
- {2020-03-11} {0.1.0-beta}
+ {2020-06-29} {0.2}
{AVMs and feature structures in LaTeX3}
\NewDocumentCommand{\avm}{ O{} +m }
{
\c_group_begin_token
\__avm_initialise_document_commands:
+ \__avm_initialise_custom_commands:
+ \tl_use:N \l__avm_defined_commands_tl
\bool_set_true:N \l__avm_mode_bool
\keys_set:nn { avm } { #1 }
\__avm_wrap:n { #2 }
@@ -55,8 +65,8 @@
\keys_define:nn { avm }
{
stretch .code:n = {\def\arraystretch{#1}},
- stretch .initial:n = {1.15},
- columnsep .dim_set:N = \arraycolsep,
+ stretch .initial:n = {0.9},
+ columnsep .dim_set:N = \tabcolsep,
columnsep .initial:n = {.5ex},
delimfactor .int_set:N = \delimiterfactor,
delimfactor .initial:n = {1000},
@@ -70,86 +80,156 @@
values .initial:n = {\itshape},
tags .code:n = {\cs_set:Nn \__avm_font_tag: {#1}},
tags .initial:n = {\footnotesize},
+ apptovalues .code:n = {\cs_set:Nn \__avm_deinit_second_column: {#1}},
+ apptovalues .initial:n = {\/},
+ singleton .code:n = {\cs_set:Nn \__avm_font_singleton: {#1}},
+ singleton .initial:n = {\normalfont},
switch .code:n = {\tl_set:Nn \__avm_mode_switch_character {#1}},
- switch .initial:n = { ! }
+ switch .initial:n = { ! },
+ extraskip .dim_set:N = \l__avm_extra_skip_dim,
+ extraskip .initial:n = {\smallskipamount},
+ customise .code:n = {\cs_set:Nn \__avm_initialise_custom_commands: {#1}},
+ customise .initial:n = { },
+ style .choice:,
+ style / narrow .code:n = {\delimiterfactor=997\delimitershortfall5pt},
+ }
+
+\NewDocumentCommand{\avmdefinestyle}{ m m }
+ {
+ \keys_define:nn { avm }
+ {
+ style / #1 .code:n = { \keys_set:nn { avm } { #2 } }
+ }
+ }
+
+\NewDocumentCommand{\avmdefinecommand}{ m O{} m }
+ {
+ \tl_put_right:Nn \l__avm_defined_commands_tl
+ {
+ \exp_args:Nc \DeclareDocumentCommand { #1 } { s }
+ {
+ #2 \IfBooleanF { ##1 } { & } \avmsetup{ #3 }
+ }
+ }
}
-\bool_new:N \l__avm_math_bool
\bool_new:N \l__avm_mode_bool
\seq_new:N \l__avm_parens_tracker
+\tl_new:N \l__avm_defined_commands_tl
\cs_generate_variant:Nn \seq_set_split:Nnn { NVn }
+\bool_new:N \l__avm_in_first_column
+
+\cs_new:Nn \__avm_init_first_column:
+ {
+ \bool_set_true:N \l__avm_in_first_column
+ \normalfont\__avm_font_attribute:
+ }
+
+\cs_new:Nn \__avm_init_second_column:
+ {
+ \bool_set_false:N \l__avm_in_first_column
+ \normalfont\__avm_font_value:
+ }
+
+\cs_new:Nn \__avm_kern_unused_columns:
+ {
+ \bool_if:NTF \l__avm_in_first_column
+ { \span\hspace*{-2\tabcolsep} }
+ { }
+ }
+
+\cs_new:Nn \__avm_extra_skip:
+ {
+ \peek_meaning_ignore_spaces:NTF \\ {\vspace*{\l__avm_extra_skip_dim}} {}
+ }
+
\cs_new:Nn \__avm_module_begin:
{
- \begin{array}{
- >{\c_math_toggle_token\normalfont\__avm_font_attribute:}l
- <\c_math_toggle_token
- >{\c_math_toggle_token\normalfont\__avm_font_value:}l
- <\c_math_toggle_token}
+ \begin{tabular}{@{}
+ >{\__avm_init_first_column:}l
+ >{\__avm_init_second_column:}l
+ <{\__avm_deinit_second_column:}
+ @{}}
}
\cs_new:Nn \__avm_module_end:
- { \end{array} }
+ {
+ \__avm_kern_unused_columns:
+ \end{tabular}
+ }
\cs_new:Nn \__avm_replace_lbrace:
{
\__avm_parse_output:nw
- { \c_math_toggle_token\left\lbrace\__avm_module_begin: }
+ { \c_math_toggle_token\left\lbrace\__avm_module_begin: }
}
\cs_new:Nn \__avm_replace_rbrace:
{
\__avm_parse_output:nw
- { \__avm_module_end:\right\rbrace\c_math_toggle_token }
+ { \__avm_module_end:\right\rbrace\c_math_toggle_token\__avm_extra_skip: }
}
\cs_new:Nn \__avm_replace_lbrack:
{
\__avm_parse_output:nw
- { \c_math_toggle_token\left\lbrack\__avm_module_begin: }
+ { \c_math_toggle_token\left\lbrack\__avm_module_begin: }
}
\cs_new:Nn \__avm_replace_rbrack:
{
\__avm_parse_output:nw
- { \__avm_module_end:\right\rbrack\c_math_toggle_token }
+ { \__avm_module_end:\right\rbrack\c_math_toggle_token\__avm_extra_skip: }
}
\cs_new:Nn \__avm_replace_lparen:
{
\__avm_parse_output:nw
- { \c_math_toggle_token\left(\__avm_module_begin: }
+ { \c_math_toggle_token\left(\__avm_module_begin: }
}
\cs_new:Nn \__avm_replace_rparen:
{
\__avm_parse_output:nw
- { \__avm_module_end:\right)\c_math_toggle_token }
+ { \__avm_module_end:\right)\c_math_toggle_token\__avm_extra_skip: }
}
\cs_new:Nn \__avm_replace_langle:
{
\__avm_parse_output:nw
- { \c_math_toggle_token\left<\__avm_module_begin: }
+ { \c_math_toggle_token\left<\__avm_module_begin: }
}
\cs_new:Nn \__avm_replace_rangle:
{
\__avm_parse_output:nw
- { \__avm_module_end:\right>\c_math_toggle_token }
+ { \__avm_module_end:\right>\c_math_toggle_token\__avm_extra_skip: }
}
\cs_new:Nn \__avm_replace_plus:
{
- \__avm_parse_output:nw { \ensuremath { \oplus } }
+ \__avm_parse_output:nw { \ensuremath { \oplus \! } }
+ }
+\cs_new:Nn \__avm_replace_minus:
+ {
+ \__avm_parse_output:nw { \ensuremath { \ominus \! } }
+ }
+\cs_new:Nn \__avm_replace_circle:
+ {
+ \__avm_parse_output:nw { \ensuremath { \bigcirc \, } }
}
\cs_new:Npn \__avm_controls_tag:n #1
{ \fboxsep.25ex\fbox{\normalfont\__avm_font_tag: #1} }
\cs_new:Npn \__avm_controls_type:n #1
- {\normalfont\__avm_font_type: #1}
+ { \c_group_begin_token\normalfont\__avm_font_type: #1\c_group_end_token }
\cs_new_protected:Npn \__avm_controls_type_starred:n #1
{
- \normalfont\__avm_font_type: #1\span
+ \bool_set_false:N \l__avm_in_first_column
+ \normalfont\__avm_font_type: #1
+ \__avm_deinit_second_column:\span\hspace*{-2\tabcolsep}
\peek_meaning_ignore_spaces:NTF \\ {} {\\}
}
\cs_new_protected:Npn \__avm_controls_punk:nn #1 #2
{
- \normalfont\c_group_begin_token\__avm_font_attribute:#1%
- \c_group_end_token\hspace{2\arraycolsep}%
- \c_group_begin_token\__avm_font_type: #2\c_group_end_token%
- \span\peek_meaning_ignore_spaces:NTF \\ {} {\\}
+ \bool_set_false:N \l__avm_in_first_column
+ \normalfont\c_group_begin_token\__avm_font_attribute:#1%
+ \c_group_end_token\hspace{2\tabcolsep}%
+ \c_group_begin_token\__avm_font_type: #2\c_group_end_token%
+ \__avm_deinit_second_column:\span\hspace*{-2\tabcolsep}
+ \peek_meaning_ignore_spaces:NTF \\ {} {\\}
}
\cs_new:Nn \__avm_initialise_document_commands:
@@ -157,6 +237,9 @@
\cs_if_exist:NTF \tag
{ \RenewDocumentCommand{\tag}{m}{ \__avm_controls_tag:n {##1} } }
{ \NewDocumentCommand{\tag}{m}{ \__avm_controls_tag:n {##1} } }
+ \cs_if_exist:NTF \0
+ { \RenewDocumentCommand{\0}{}{ \__avm_controls_tag:n {0} } }
+ { \NewDocumentCommand{\0}{}{ \__avm_controls_tag:n {0} } }
\cs_if_exist:NTF \1
{ \RenewDocumentCommand{\1}{}{ \__avm_controls_tag:n {1} } }
{ \NewDocumentCommand{\1}{}{ \__avm_controls_tag:n {1} } }
@@ -264,7 +347,9 @@
{
\str_case:nnF {#1}
{
- { + }{ \__avm_replace_plus: }
+ { \+ }{ \__avm_replace_plus: }
+ { \- }{ \__avm_replace_minus: }
+ { \shuffle }{ \__avm_replace_circle: }
{ [ }{ \__avm_replace_lbrack: }
{ ] }{ \__avm_replace_rbrack: }
{ ( }{ \__avm_replace_lparen: }