summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/exsheets
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-06-28 21:55:58 +0000
committerKarl Berry <karl@freefriends.org>2013-06-28 21:55:58 +0000
commit864a1bbab21506fbb07551883dfca2ad457f2514 (patch)
tree630558a1f9e533f65ab5339e6d6a9748bff2c5b0 /Master/texmf-dist/tex/latex/exsheets
parent35f4733179fc116420810062bf3bd6891f86b5d9 (diff)
exsheets (28jun13)
git-svn-id: svn://tug.org/texlive/trunk@31008 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/exsheets')
-rw-r--r--Master/texmf-dist/tex/latex/exsheets/exsheets.sty67
-rw-r--r--Master/texmf-dist/tex/latex/exsheets/translations.sty208
2 files changed, 188 insertions, 87 deletions
diff --git a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
index 32234196478..9d899f2d815 100644
--- a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
+++ b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
@@ -31,8 +31,8 @@
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% ----------------------------------------------------------------------------
-\def\exsheets@date{2013/05/26}
-\def\exsheets@version{0.9f}
+\def\exsheets@date{2013/06/28}
+\def\exsheets@version{0.9h}
\RequirePackage { expl3 , xparse }
\ProvidesExplPackage
@@ -1015,7 +1015,7 @@
\bool_if:NT \l__exsheets_auto_label_bool
{
\exp_args:Nx \label { qu : \g__exsheets_questions_current_id_tl }
- \exp_args:Nx \SetQuestionProperties
+ \exsheets_set_question_properties:x
{
ref = \exp_not:N \ref { qu : \g__exsheets_questions_current_id_tl } ,
pageref = \exp_not:N \pageref { qu : \g__exsheets_questions_current_id_tl }
@@ -1024,7 +1024,7 @@
}
{
\exp_args:Nx \label { \l__exsheets_questions_label_tl }
- \exp_args:Nx \SetQuestionProperties
+ \exsheets_set_question_properties:x
{
ref = \exp_not:N \ref { \l__exsheets_questions_label_tl } ,
pageref = \exp_not:N \pageref { \l__exsheets_questions_label_tl }
@@ -1067,7 +1067,7 @@
\fp_set_eq:NN
\l__exsheets_question_points_fp
\l__exsheets_points_default_fp
- \exp_args:Nx \SetQuestionProperties
+ \exsheets_set_question_properties:x
{ points = \fp_to_tl:N \l__exsheets_points_default_fp }
}
}
@@ -1076,7 +1076,7 @@
\g__exsheets_this_question_points_fp
\l__exsheets_question_points_fp
\__exsheets_read_points:n { #2 }
- \SetQuestionProperties{points=#2}
+ \exsheets_set_question_properties:n { points = #2 }
}
\tl_if_blank:VT \l__exsheets_question_heading_instance_tl
{
@@ -1164,7 +1164,7 @@
{
\fp_compare:nT { \g__exsheets_this_question_points_fp > 0 }
{
- \exp_args:Nx \SetQuestionProperties
+ \exsheets_set_question_properties:x
{ points = \fp_to_tl:N \g__exsheets_this_question_points_fp }
}
}
@@ -1179,7 +1179,9 @@
\cs_new_protected:Npn \__exsheets_save_number_in_aux_x:Nnn #1#2#3
{
\prop_gput:Nfx #1 { #2 } { #3 }
- \iow_now:Nx \@auxout { \exsheets@save@number { #2 } { #3 } }
+ \if@filesw
+ \iow_now:Nx \@auxout { \exsheets@save@number { #2 } { #3 } }
+ \fi
}
\cs_new_protected:Npn \__exsheets_save_number_in:N #1
@@ -1335,6 +1337,7 @@
}
\@esphack
}
+\cs_generate_variant:Nn \exsheets_set_question_properties:n { x }
\NewDocumentCommand \SetQuestionProperties { m }
{ \exsheets_set_question_properties:n { #1 } }
@@ -1882,20 +1885,22 @@
\cs_new_protected:Npn \__exsheets_exlabel:n #1
{
\@bsphack
- \iow_now:Nx \@auxout
- {
- \token_to_str:N \newlabel { exse:#1 }
- { { \arabic { section } } { \thepage } }
- }
- \cs_if_exist:NT \thechapter
- {
- \iow_now:Nx \@auxout
- {
- \token_to_str:N \newlabel { exch:#1 }
- { { \arabic { chapter } } { \thepage } }
- }
- }
- \@esphack
+ \if@filesw
+ \iow_now:Nx \@auxout
+ {
+ \token_to_str:N \newlabel { exse:#1 }
+ { { \arabic { section } } { \thepage } }
+ }
+ \cs_if_exist:NT \thechapter
+ {
+ \iow_now:Nx \@auxout
+ {
+ \token_to_str:N \newlabel { exch:#1 }
+ { { \arabic { chapter } } { \thepage } }
+ }
+ }
+ \@esphack
+ \fi
}
% user command:
@@ -2547,13 +2552,15 @@
% save total points in .aux file to make it available for \allpoints anywhere
\AtEndDocument
{
- \iow_now:Nx \@auxout
- {
- \exp_not:N \exsheets@sum@of@points
- { \fp_eval:n { \g__exsheets_points_sum_fp } }^^J
- \exp_not:N \exsheets@sum@of@bonus
- { \fp_eval:n { \g__exsheets_bonus_sum_fp } }
- }
+ \if@filesw
+ \iow_now:Nx \@auxout
+ {
+ \exp_not:N \exsheets@sum@of@points
+ { \fp_eval:n { \g__exsheets_points_sum_fp } }^^J
+ \exp_not:N \exsheets@sum@of@bonus
+ { \fp_eval:n { \g__exsheets_bonus_sum_fp } }
+ }
+ \fi
}
% ----------------------------------------------------------------------------
@@ -2690,6 +2697,8 @@ HISTORY:
option is enabled and questions/solutions are at the
top of a new page because there wasn't enough place
left at the page before
+2013/05/30 v0.9g - obey \if@filesw
+2013/06/28 v0.9h - cleaner internal use of \exsheets_set_question_properties:n
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TODO:
diff --git a/Master/texmf-dist/tex/latex/exsheets/translations.sty b/Master/texmf-dist/tex/latex/exsheets/translations.sty
index 1f46c1ca8ce..9f751632426 100644
--- a/Master/texmf-dist/tex/latex/exsheets/translations.sty
+++ b/Master/texmf-dist/tex/latex/exsheets/translations.sty
@@ -28,8 +28,8 @@
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% --------------------------------------------------------------------------
-\def\@trnslt@date{2013/04/08}
-\def\@trnslt@version{v0.9a}
+\def\@trnslt@date{2013/06/28}
+\def\@trnslt@version{v0.10}
\ProvidesPackage{translations}[\@trnslt@date\space \@trnslt@version\space a simple translator]
\RequirePackage{etoolbox}
@@ -37,7 +37,7 @@
% --------------------------------------------------------------------------
% message handling
\def\@trnslt@error@message{%
- For details have a look at the `exsheets' manual.}
+ For details have a look at the `translations' manual.}
\def\@trnslt@create@message#1{%
\ifstrequal{#1}{Error}
@@ -80,6 +80,14 @@
{\long\def\bbl@afterfi#1\fi{\fi#1}}
}
+% book keeping: the following macros will be used as `etoolbox' lists that
+% keep record of defined languages, dialects and aliases
+\def\@trnslt@languages{}
+\def\@trnslt@aliases@pair{}
+\def\@trnslt@aliases@single{}
+\def\@trnslt@dialects@pair{}
+\def\@trnslt@dialects@single{}
+
% --------------------------------------------------------------------------
% \DeclareLanguage and \DeclareLanguageAlias
% #1: language
@@ -88,51 +96,102 @@
\@onlypreamble\DeclareLanguage
\def\@trnslt@declare@language#1{%
- \csdef{@trnslt@language@#1}{#1}}
+ \@trnslt@if@language{#1}
+ {}{%
+ \csdef{@trnslt@language@#1}{#1}%
+ \listeadd\@trnslt@languages{#1}%
+ }%
+}
-% #1: alias
+\def\@trnslt@language#1{%
+ \csuse{@trnslt@language@#1}}
+
+\def\@trnslt@if@language#1{%
+ \ifcsundef{@trnslt@language@#1}
+ {\expandafter\@secondoftwo}
+ {\expandafter\@firstoftwo}%
+}
+
+% #1: dialect
% #2: language
-\newrobustcmd*\DeclareLanguageAlias[2]{%
- \@trnslt@declare@languagealias{#1}{#2}}
-\@onlypreamble\DeclareLanguageAlias
+\newrobustcmd*\DeclareLanguageDialect[2]{%
+ \@trnslt@declare@languagedialect{#1}{#2}}
+\@onlypreamble\DeclareLanguageDialect
-\def\@trnslt@declare@languagealias#1#2{%
- \ifcsdef{@trnslt@language@#2}
+\def\@trnslt@declare@languagedialect#1#2{%
+ \@trnslt@if@language{#2}
{}{%
\@trnslt@warn@unknown@lang{#2}%
\@trnslt@declare@language{#2}%
}%
- \lowercase{\@trnslt@if@dialect{#2}}{#2}
- {%
- \csletcs
- {@trnslt@language@\@trnslt@language{#2}@dialect@#1}
- {@trnslt@language@\@trnslt@language{#2}@dialect@#2}%
+ \@trnslt@if@dialect{#1}
+ {% => ist schon als dialect definiert => irgendwelche weiteren checks?
}
- {}%
- \csletcs{@trnslt@language@#1}{@trnslt@language@#2}}
+ {%
+ \@trnslt@if@alias{#2}
+ {%
+ \csedef{@trnslt@dialect@#1}{{\@trnslt@alias{#2}}{#1}}%
+ \@trnslt@declare@language{#1}%
+ \listeadd\@trnslt@dialects@single{#1}%
+ \listeadd\@trnslt@dialects@pair{{#1}{\@trnslt@alias{#2}}}%
+ }
+ {%
+ \csdef{@trnslt@dialect@#1}{{#2}{#1}}%
+ \@trnslt@declare@language{#1}%
+ \listeadd\@trnslt@dialects@single{#1}%
+ \listeadd\@trnslt@dialects@pair{{#1}{#2}}%
+ }%
+ }%
+}
-% #1: dialect
+\def\@trnslt@dialect#1{%
+ \csuse{@trnslt@dialect@#1}}
+
+\def\@trnslt@dialect@of#1{%
+ \expandafter\expandafter\expandafter
+ \@trnslt@dialect@of@aux
+ \csname @trnslt@dialect@#1\endcsname\@empty
+}
+\def\@trnslt@dialect@of@aux#1#2{\ifx\relax#1\@empty\else#1\fi}
+
+\def\@trnslt@if@dialect#1{%
+ \ifcsundef{@trnslt@dialect@#1}
+ {\expandafter\@secondoftwo}
+ {\expandafter\@firstoftwo}%
+}
+
+% #1: alias
% #2: language
-\newrobustcmd*\DeclareLanguageDialect[2]{%
- \@trnslt@declare@languagedialect{#1}{#2}}
-\@onlypreamble\DeclareLanguageDialect
+\newrobustcmd*\DeclareLanguageAlias[2]{%
+ \@trnslt@declare@languagealias{#1}{#2}}
+\@onlypreamble\DeclareLanguageAlias
-\def\@trnslt@declare@languagedialect#1#2{%
- \ifcsdef{@trnslt@language@#2}
+\def\@trnslt@declare@languagealias#1#2{%
+ \@trnslt@if@language{#2}
{}{%
\@trnslt@warn@unknown@lang{#2}%
\@trnslt@declare@language{#2}%
}%
- \csdef{@trnslt@language@\@trnslt@language{#2}@dialect@#1}{}%
- \csletcs{@trnslt@language@#1}{@trnslt@language@#2}}
+ \csletcs{@trnslt@language@#1}{@trnslt@language@#2}%
+ \@trnslt@if@dialect{#2}
+ {\csletcs{@trnslt@dialect@#1}{@trnslt@dialect@#2}}
+ {}%
+ \ifinlist{#1}\@trnslt@aliases@single
+ {}{%
+ \csdef{@trnslt@alias@#1}{#2}%
+ \listeadd\@trnslt@aliases@pair{{#1}{#2}}%
+ \listeadd\@trnslt@aliases@single{#1}%
+ }%
+}
-\def\@trnslt@if@dialect#1#2{%
- \ifcsdef{@trnslt@language@\@trnslt@language{#2}@dialect@#1}
- {\expandafter\@firstoftwo}
- {\expandafter\@secondoftwo}}
+\def\@trnslt@alias#1{%
+ \csuse{@trnslt@alias@#1}}
-\def\@trnslt@language#1{%
- \csuse{@trnslt@language@#1}}
+\def\@trnslt@if@alias#1{%
+ \ifcsundef{@trnslt@alias@#1}
+ {\expandafter\@secondoftwo}
+ {\expandafter\@firstoftwo}%
+}
% dummy language: `fallback':
\DeclareLanguage{fallback}
@@ -151,37 +210,56 @@
\@trnslt@declare@translation{#1}{fallback}{#2}}
\@onlypreamble\DeclareTranslationFallback
+\newrobustcmd*\NewTranslation[3]{%
+ \@trnslt@new@translation{#2}{#1}{#3}}
+\@onlypreamble\NewTranslation
+
+\newrobustcmd*\RenewTranslation[3]{%
+ \@trnslt@renew@translation{#2}{#1}{#3}}
+\@onlypreamble\RenewTranslation
+
+% #1: word
+% #2: language
+% #3: replacement
\def\@trnslt@declare@translation#1#2#3{%
- \ifcsdef{@trnslt@language@#2}
+ \@trnslt@if@language{#2}
{%
+ % save the <word> as <word>:
\csdef{@trnslt@word@#1@literal}{#1}%
- \lowercase{\@trnslt@if@dialect{#2}}{#2}
- {\csdef{@trnslt@word@#1@#2}{#3}}
+ % check if the language is a dialect:
+ \@trnslt@if@dialect{#2}
+ {\csdef{@trnslt@word@#1@\@trnslt@dialect{#2}}{#3}}
{}%
- \ifcsdef{@trnslt@word@#1@\@trnslt@language{#2}}
+ % check if translation already exists:
+ \@trnslt@if@translation{#1}{#2}
{}
{\csdef{@trnslt@word@#1@\@trnslt@language{#2}}{#3}}%
}
- {\@trnslt@err@unknown@lang{#2}}}
+ {\@trnslt@err@unknown@lang{#2}}%
+}
\def\@trnslt@if@translation#1#2{%
- \ifcsdef{@trnslt@word@#1@\@trnslt@language{#2}}
- {\expandafter\@firstoftwo}
- {\expandafter\@secondoftwo}}
-
-\newrobustcmd*\NewTranslation[3]{%
- \@trnslt@new@translation{#2}{#1}{#3}}
-\@onlypreamble\NewTranslation
+ \ifcsundef{@trnslt@word@#1@\@trnslt@language{#2}}
+ {%
+ \@trnslt@if@dialect{#2}
+ {%
+ \ifboolexpe{
+ test {\ifcsundef{@trnslt@word@#1@\@trnslt@dialect{#2}}} or
+ test {\ifcsundef{@trnslt@word@#1@\@trnslt@dialect@of{#2}}}
+ }
+ {\expandafter\@firstoftwo}
+ {\expandafter\@secondoftwo}%
+ }
+ {\expandafter\@secondoftwo}%
+ }
+ {\expandafter\@firstoftwo}%
+}
\def\@trnslt@new@translation#1#2#3{%
\@trnslt@if@translation{#1}{#2}
{\@trnslt@err@already@defined{#1}{#2}}
{\@trnslt@declare@translation{#1}{#2}{#3}}}
-\newrobustcmd*\RenewTranslation[3]{%
- \@trnslt@renew@translation{#2}{#1}{#3}}
-\@onlypreamble\RenewTranslation
-
\def\@trnslt@renew@translation#1#2#3{%
\@trnslt@if@translation{#1}{#2}
{\@trnslt@declare@translation{#1}{#2}{#3}}
@@ -200,16 +278,18 @@
% #1: word #2: language
\def\@trnslt@get@translation@for#1#2{%
- \@trnslt@if@translation{#1}{#2}
+ \@trnslt@if@dialect{#2}
{%
- \@trnslt@if@dialect{#2}{#2}
- {%
- \ifcsdef{@trnslt@word@#1@#2}
- {\csuse{@trnslt@word@#1@#2}}
- {\csuse{@trnslt@word@#1@\@trnslt@language{#2}}}%
- }
- {\csuse{@trnslt@word@#1@\@trnslt@language{#2}}}%
+ \ifcsdef{@trnslt@word@#1@\@trnslt@dialect{#2}}
+ {\csuse{@trnslt@word@#1@\@trnslt@dialect{#2}}}
+ {\csuse{@trnslt@word@#1@\@trnslt@dialect@of{#2}}}%
}
+ {\csuse{@trnslt@word@#1@\@trnslt@language{#2}}}%
+}
+
+\def\@trnslt@getandcheck@translation@for#1#2{%
+ \@trnslt@if@translation{#1}{#2}
+ {\@trnslt@get@translation@for{#1}{#2}}
{%
\@trnslt@warning{Translation for `#1' in #2 unknown. You may try to use
\string\DeclareTranslation{#2}{#1}{ ... } in your preamble.}%
@@ -219,7 +299,8 @@
\csuse{@trnslt@word@#1@fallback}
}%
{\csuse{@trnslt@word@#1@literal}}%
- }}
+ }%
+}
% --------------------------------------------------------------------------
% \SaveTranslationFor and \SaveTranslation
@@ -329,8 +410,8 @@
\DeclareLanguageDialect{canadian}{english}
\DeclareLanguageAlias {Canadian}{canadian}
\DeclareLanguageAlias {English}{english}
-\DeclareLanguageDialect{UKenglish}{english}
-\DeclareLanguageDialect{USenglish}{english}
+\DeclareLanguageAlias {UKenglish}{british}
+\DeclareLanguageAlias {USenglish}{american}
\DeclareLanguageDialect{austrian}{german}
\DeclareLanguageAlias {Austrian}{austrian}
\DeclareLanguageAlias {German}{german}
@@ -365,6 +446,10 @@
\DeclareLanguageAlias {Slovenian}{slovenian}
\DeclareLanguageAlias {Spanish}{spanish}
\DeclareLanguageAlias {Swedish}{swedish}
+\DeclareLanguageDialect{swissgerman}{german}
+% this maybe should be a language of it's own:
+\DeclareLanguageAlias {Swiss}{swissgerman}
+\DeclareLanguageAlias {Swissgerman}{swissgerman}
\DeclareLanguageAlias {Turkish}{turkish}
\DeclareLanguageAlias {Ukrainian}{ukrainian}
@@ -381,3 +466,10 @@
2013/04/08 v0.9a - changed fallback warning into info
- synchronized version number with `exsheets' until now but
won't any more
+2013/06/22 v0.9b - added Swiss
+2013/06/28 v0.10 - declaring aliases of dialects now works as expected
+ - declarings dialects of an alias now correctly declares
+ the dialect to the correct base language
+ - corrected a few erroneous langugae declarations
+
+