diff options
author | Norbert Preining <norbert@preining.info> | 2021-05-15 03:01:02 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-05-15 03:01:02 +0000 |
commit | ff5439d00ba53d3e4b82d79f78ce65524f3684fd (patch) | |
tree | 109b3899cf0fd6e1bc480dbbe1793b7b29de416a /macros/latex/contrib | |
parent | 11a1186b093ff2ae9478c20979b6eec30f63f32c (diff) |
CTAN sync 202105150301
Diffstat (limited to 'macros/latex/contrib')
54 files changed, 4572 insertions, 2306 deletions
diff --git a/macros/latex/contrib/easybook/easybook.dtx b/macros/latex/contrib/easybook/easybook.dtx index b25fb33c37..cf81762704 100644 --- a/macros/latex/contrib/easybook/easybook.dtx +++ b/macros/latex/contrib/easybook/easybook.dtx @@ -24,11 +24,11 @@ % \changes{v1.20}{2021/01/09}{修改和完善用户文档。} % \changes{v1.20}{2021/01/09}{模板更改为使用 CC-BY 许可协议。} % \changes{v1.23}{2021/03/19}{修复在 \pkg{ctex} v2.5.6 更新后 \cls{easybook} 与 \pkg{hyperref} 冲突问题。} -% \changes{v1.25h}{2021/05/03}{取消附带的示例文件,可查看历史版本及其它来源的使用样例。} +% \changes{v1.25i}{2021/05/03}{取消附带的示例文件,可查看历史版本及其它来源的使用样例。} % % \title{\sffamily easybook 文档类手册} % \author{瞿毅} -% \date{2021/05/12\hskip\ccwd\relax v1.25h\thanks{\url{https://gitee.com/texl3/easybook}}} +% \date{2021/05/14\hskip\ccwd\relax v1.25i\thanks{\url{https://gitee.com/texl3/easybook}}} % % \maketitle % \begin{abstract} @@ -118,7 +118,7 @@ % \end{syntax} % 传递给 \cls{ctexbook} 设置字体,最好不要使用原有的 \opt{fontset} 选项,默认情况下使用自定义字体而不开启这个选项,可根据安装的字体及电脑系统选取。\opt{noto} 与 \opt{none} 选项的相关描述见小节 \ref{subsec:font settings},\opt{overleaf} 是一个各系统通用选项,会检测系统环境选取对应字体。 % \changes{v1.21}{2021/01/12}{默认字体与 \CTeX 一致,不再是自定义字体。} -% \changes{v1.25h}{2021/05/04}{修复使用 \pkg{xeCJK} 与 \pkg{fontspec} 宏包的字体设置命令在 \hologo{LuaLaTeX} 下失效的问题。} +% \changes{v1.25i}{2021/05/04}{修复使用 \pkg{xeCJK} 与 \pkg{fontspec} 宏包的字体设置命令在 \hologo{LuaLaTeX} 下失效的问题。} % \end{function} % % \begin{function}[rEXP,added = 2021-01-05,updated = 2021-01-13]{paper} @@ -169,7 +169,7 @@ % \tn{listoflistings*+}\oarg{键值列表} % \end{syntax} % \tn{listoffigures} 命令输出图片目录,\tn{listoftables} 输出表格目录,\tn{listoflistings} 输出代码目录。带有星号的目录命令不将标题添加进主文档目录,带有+号的目录命令可以使当前标题编号。\tn{tableofcontents+} 与其它命令不同是用于输出双语目录,需要与双语目录标题命令 \tn{bichapter} 等或设置图片、表格和代码等英文目录的标题配合使用,附加代码是中文与英文目录之间的代码,可以插入文本和换页命令等。目录的键值列表选项如下 -% \changes{v1.25h}{2021/05/05}{命令 \tn{tableofcontents} 可以输出双语目录。} +% \changes{v1.25i}{2021/05/05}{命令 \tn{tableofcontents} 可以输出双语目录。} % \end{function} % % \begin{function}{multoc,title,format,aftertitle,pagestyle,book,article} @@ -200,7 +200,7 @@ % 双语目录的标题命令目前设置了常用的三个级别,它们将中文标题正常输出,并使中英文标题加入双语目录,这个功能是为国内一些大学的学位论文模板的要求设计,在一般情况和英文模式下不需要使用。 % % 它们的星号变体命令使文中标题不编号,但是仍然加入双语目录,若英文标题参数空置那么仅加入中文目录而不加入英文目录,这一特点与 \tn{chapter*} 等命令的行为不太一样,在一些情况下会用到。可选参数是目录中的中文标题,默认与中文标题一致,正文标题过长时可用它设置在目录中显示的标题。双语目录的格式是一致的,共享使用 \tn{tocset} 的设置,英文目录的章级别标题名及编号的修改方式如下 -% \changes{v1.25h}{2021/05/05}{增加与双语目录配合的标题命令。} +% \changes{v1.25i}{2021/05/05}{增加与双语目录配合的标题命令。} % \end{function} % % \begin{function}{biname,binmuber} @@ -288,9 +288,9 @@ % % \subsection{超链接} % \label{subsec:hyperlinks} -% \begin{function}[EXP,added = 2021-01-05,updated = 2021-05-06]{hyperlink,linkcolor,linkcol-all,linktoc} +% \begin{function}[EXP,added = 2021-01-05,updated = 2021-05-06]{linktype,linkcolor,linkcol-all,linktoc} % \begin{syntax} -% hyperlink = <(edge)|various|none> +% linktype = <(edge)|various|none> % linkcolor = <fresh|cutepink|(navyblue)|crimson> % linkcol-all = <HTML颜色代码> % linktoc = <none|section|page|(all)> @@ -299,11 +299,11 @@ % \opt{refset} 将超链接选项(包括以上选项)交给 \pkg{hyperref} 处理,除了一些关于 pdf 书签的选项可能会失效,其它由键值选项命令 \tn{hypersetup} 支持的多数选项可用。 % \changes{v1.10}{2021/01/08}{修复了 \opt{linktopage} 选项关闭时目录中标题编号无超链接的问题。} % \changes{v1.24}{2021/04/05}{增加 \pkg{hyperref} 超链接选项完整的支持。} -% \changes{v1.25h}{2021/05/06}{模块名 \opt{link} 改为 \opt{refset},\opt{link} 作为兼容性保留。} +% \changes{v1.25i}{2021/05/06}{模块名 \opt{link} 改为 \opt{refset},\opt{link} 作为兼容性保留。} % \end{function} % % \begin{optdesc} -% \item[hyperlink] \opt{edge} 使超链接为边框形式,\opt{various} 使超链接为彩色字体,有四种颜色风格。\opt{none} 关闭超链接边框与颜色,此时 \opt{linkcolor} 选项无效。 +% \item[linktype] \opt{edge} 使超链接为边框形式,\opt{various} 使超链接为彩色字体,有四种颜色风格。\opt{none} 关闭超链接边框与颜色,此时 \opt{linkcolor} 选项无效。 % \item[linkcolor] 超链接颜色样式。 % \begin{function}{ctex@link,ctex@url,ctex@cite} % \begin{syntax} @@ -378,7 +378,7 @@ % \changes{v1.21}{2021/01/11}{增加 \opt{bibset} 选项,可以使用 \hologo{BibTeX} 或 \hologo{biber} 编译参考文献。} % \changes{v1.23}{2021/02/23}{使用 \opt{bibset} 选项时可设置标注风格。} % \changes{v1.24}{2021/04/09}{可以不载入参考文献包手动配置参考文献格式。} -% \changes{v1.25h}{2021/05/12}{取消 \opt{bib-loadpkg} 选项,由是否设置参考文献数据库来决定载入宏包。} +% \changes{v1.25i}{2021/05/12}{取消 \opt{bib-loadpkg} 选项,由是否设置参考文献数据库来决定载入宏包。} % \end{function} % % \begin{optdesc} @@ -572,12 +572,12 @@ % 上面几个选项用于设置脚注格式,\opt{fnparskip} 和 \opt{fnparindent} 选项仅在 \opt{fnhang = true} 时有效。\opt{fnhang} 用于将脚注设置为悬挂缩进的格式,\opt{fnmark-pos} 选项设置脚注编号的位置,正常文本或是上标形式。\opt{fnmark-num} 选项设置脚注编号的格式,默认为原生样式 \opt{plain},还可以改为 \opt{pifont} 的各个版本,从左往右依次为普通版、阴文衬线版、阳文无衬线版和阴文无衬线版,缺点是它们的编号仅包括1-10。 % % \opt{fnmark-form} 是脚注标记的格式,默认为空,在此设置字体命令会覆盖 \opt{elsefont/footnote} 的设置,最后一个格式命令可以带有一个参数,这个参数接受脚注编号,一般配合 \opt{fnmark-num = plain} 使用。\opt{afterfnmark} 是脚注标记后的代码,一般用于设置标记与文本间的距离。 -% \changes{v1.25h}{2021/05/12}{增加脚注样式设置选项。} +% \changes{v1.25i}{2021/05/12}{增加脚注样式设置选项。} % \end{function} % % \subsection{目录样式} % \label{subsec:catalog style} -% \begin{function}[EXP,added = 2021-01-13,updated = 2021-05-01]{format,format+,indent,rule,numsep} +% \begin{function}[EXP,added = 2021-01-13,updated = 2021-05-14]{format,format+,indent,rule,numsep} % \begin{syntax} % format = <目录标题格式> % format += <目录标题格式> @@ -586,11 +586,12 @@ % numsep = <编号后间距|(\tn{ccwd})> % \end{syntax} % \ding{229} 以上选项路径为 \opt{tocset/(level)/...} \\ -% \opt{tocset} 将目录样式交给 \pkg{titletoc} 处理,\opt{level} 代表 \opt{part}、\opt{chapter}、\opt{section}、\opt{subsection} 和 \opt{list} 五种级别的目录样式设置,其中 \opt{list} 为图片、表格和代码目录样式的级别。 +% \opt{tocset} 将目录样式交给 \pkg{titletoc} 处理,\opt{level} 代表 part、chapter、section、subsection、figure、table 和 lstlisting 级别的目录,而使用 \opt{list} 级别可以统一设置图片、表格和代码目录的样式。 % % \opt{format} 是目录中标题的格式,可以设置字体和加入垂直间距等,垂直间距最好使用无间距重合的 \tn{addvspace} 命令,带有加号的 \opt{format+} 选项用于在已有的格式命令后附加内容。\opt{indent} 是目录中标题在页面左侧的缩进距离,应该有长度单位。\opt{rule} 选项中一般应当使用 \tn{tocrule} 命令,将会在接下来介绍。\opt{numsep} 是有编号的标题在目录中编号与标题的间距。 % \changes{v1.21}{2021/01/13}{增加配置目录样式的选项。} % \changes{v1.24}{2021/04/20}{增加目录中编号与标题的间距选项 \opt{numsep}。} +% \changes{v1.25i}{2021/05/14}{可以分别设置图片、表格和代码目录的格式。} % \end{function} % % \begin{function}[added = 2021-01-13,updated = 2021-04-20]{\tocrule,\EbNumberline} @@ -615,10 +616,10 @@ % } % \end{ctexexam} % -% \begin{function}[EXP,added = 2021-01-13,updated = 2021-05-01]{list/lolskip,list/belowoffset,tocset/tocline-fig,tocset/tocline-tab,tocset/tocline-lst,tocset/belowoffset,tocset/line-align,tocset/hang,tocset/numsep-all,tocset/indent-all,tocset/rule-all} +% \begin{function}[EXP,added = 2021-01-13,updated = 2021-05-14]{level/belowoffset,lolskip,tocline-fig,tocline-tab,tocline-lst,belowoffset,line-align,hang,numsep-all,indent-all,rule-all} % \begin{syntax} -% lolskip = <(0.8pc)> % belowoffset = <(0pc)> +% lolskip = <(0.8pc)> % tocline-fig = <图片目录标签> % tocline-tab = <表格目录标签> % tocline-lst = <代码目录标签> @@ -629,7 +630,7 @@ % indent-all = <目录标题左边缩进> % rule-all = <目录引导线样式> % \end{syntax} -% \ding{229} 以上选项路径为 \opt{tocset/list/...} 或 \opt{tocset/...} +% \ding{229} 以上选项路径为 \opt{tocset/level/...} 或 \opt{tocset/...} % \changes{v1.24}{2021/04/05}{可以设置图、表和代码目录的标签。} % \changes{v1.24}{2021/04/06}{增加目录引导线右边对齐方式。} % \changes{v1.24}{2021/04/19}{给目录增加 \opt{hang} 样式选项。} @@ -638,7 +639,7 @@ % % \begin{optdesc} % \item[lolskip] \opt{lolskip} 是代码目录中章之间的代码标题的距离,与 \CTeX 的表格目录和图片目录中章之间的标题距离选项 \opt{lotskip} 和 \opt{lofskip} 类似,它们的值均默认0.8 pc,在 \opt{article} 模式中此选项失效。 -% \item[belowoffset] \opt{belowoffset} 选项为主目录标题 \tn{contentsname} 后的间距补偿,一般为负值,用于抵消 \opt{format} 中设置的垂直间距。\opt{list} 中的 \opt{belowoffset} 与之意义类似,但是一般为正值,可以在 \opt{article} 模式中使用。建议 \opt{list/lolskip(0.8pc) + list/format/addvspace(0.2pc) + list/belowoffset(0pc) = belowoffset(-1pc)}。 +% \item[belowoffset] \opt{belowoffset} 选项为主目录标题 \tn{contentsname} 后的间距补偿,一般为负值,用于抵消 \opt{format} 中设置的垂直间距。\opt{level} 中的 \opt{belowoffset} 与之意义类似,代表 figure、table 和 lstlisting 三个级别,也可以使用 \opt{list} 统一设置,一般为正值。建议 \opt{lolskip(0.8pc) + list/format/addvspace(0.2pc) + list/belowoffset(0pc) = belowoffset(-1pc)}。 % \item[tocline] 目录标签整体使用 \opt{tocline} 设置,在图表标签的参数中\#1代表编号,代码标签中则是 \tn{thelstlisting} 代表编号,标签中还可包含标签名称,默认标签名称与图、表和代码环境的标题名称一致。下面举个设置标签的例子 % \begin{ctexexam} % \tocset @@ -966,7 +967,7 @@ %<*class> \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{l3keys2e,etoolbox} -\ProvidesExplClass{easybook}{2021/05/12}{1.25h}{beta} +\ProvidesExplClass{easybook}{2021/05/14}{1.25i}{beta} \cs_generate_variant:Nn \eb_ctex_define:nn { nx } \cs_generate_variant:Nn \int_to_arabic:n { v } @@ -1091,9 +1092,10 @@ \seq_map_inline:Nn \c__eb_options_path_seq { \ctex_define:n { #1 .meta:nn = { ctex/#1 } {##1} } - \cs_new:cpn {#1} ##1 { \keys_set:nn {ctex/#1} {##1} } + \cs_new:cpn {#1} ##1 { \keys_set:nn { ctex/#1 } {##1} } } \keys_define:nn { } { ctex/link .inherit:n = ctex/refset } +\cs_set_eq:NN \link \refset \ctex_define:n { link .meta:nn = { ctex/link } {#1}, @@ -1425,7 +1427,7 @@ \cs_new:Npn \eb_upper_number_mark_bool:nn #1#2 { \bool_if:NT \l__eb_uppercase_bool - { \text_uppercase:n } { \use:c { eb_fancyhf_#1_mark:n } {#2} } + { \text_uppercase:n } {\use:c { eb_fancyhf_#1_mark:n } {#2}} } \cs_new:Npn \eb@number@markdouble #1#2 { @@ -1521,7 +1523,7 @@ { \hbox:n { - \tl_if_eq:NnT \l__eb_fnmark_position_tl {super} + \tl_if_eq:NnT \l__eb_fnmark_position_tl { super } { \textsuperscript }{\@thefnmark} \tl_use:N \l__eb_fnmark_after_tl } @@ -1567,9 +1569,10 @@ { \int_use:N #1 } } -\seq_const_from_clist:Nn \c__eb_toc_headings_level_seq - { part,chapter,section,subsection,list } -\seq_map_inline:Nn \c__eb_toc_headings_level_seq +\contentsuse{lstlisting}{lol} +\seq_const_from_clist:Nn \c__eb_toc_heading_level_seq + { part,chapter,section,subsection,figure,table,lstlisting } +\cs_new_protected:Npn \eb_toc_assign_keys:n #1 { \ctex_define:n { tocset/#1 .meta:nn = { ctex/tocset/#1 } {##1} } \eb_ctex_define:nn { tocset } @@ -1583,6 +1586,46 @@ #1/rule .tl_set:c = l__eb_toc_#1_rule_tl, #1/numsep .tl_set:c = eb@toc@#1@numsep } + \seq_if_in:NnF \c__eb_toc_heading_level_seq { subsection } + { + \eb_ctex_define:nn { tocset } + { #1/belowoffset .dim_set:c = l__eb_toc_#1_offset_dim } + } + \seq_pop:NN \c__eb_toc_heading_level_seq \l_tmpa_tl + \titlecontents{#1} + [\use:c { l__eb_toc_#1_indent_tl }] + {\use:c { l__eb_toc_#1_format_tl }} + { + \ifbool{eb@titletoc@hang@fix} + { + \contentspush + { + \bool_if:NT \l__eb_toc_number_color_bool + { \color{ctex@toc@number} } + \thecontentslabel + \hspace{\use:c { eb@toc@#1@numsep }} + } + }{} + }{} + {\use:c { l__eb_toc_#1_rule_tl }} + } +\seq_map_function:NN +\c__eb_toc_heading_level_seq \eb_toc_assign_keys:n + +\seq_const_from_clist:Nn \c__eb_toc_list_meta_keys_seq + { format,format+,format~+,indent,rule,numsep,belowoffset } +\ctex_define:n { tocset/list .meta:nn = { ctex/tocset/list } {#1} } +\seq_map_inline:Nn \c__eb_toc_list_meta_keys_seq + { + \eb_ctex_define:nn { tocset } + { + list/#1 .meta:n = + { + figure/#1 = ##1, + table/#1 = ##1, + lstlisting/#1 = ##1 + } + } } \cs_new:Npn \EbNumberline #1 @@ -1596,11 +1639,8 @@ \newbool{eb@titletoc@hang@fix} \eb_ctex_define:nn { tocset } { - list/lolskip .skip_set:N = \l__eb_toc_lolskip_skip, - list/lolskip .initial:n = 0.8pc, - list/belowoffset .dim_set:N = \l__eb_toc_listoffset_dim, - list/belowoffset .initial:n = - { \bool_if:NTF \l__eb_class_book_bool { 0pc } { 0.15pc } }, + lolskip .skip_set:N = \l__eb_toc_lolskip_skip, + lolskip .initial:n = 0.8pc, belowoffset .dim_set:N = \l__eb_toc_offset_dim, belowoffset .initial:n = @@ -1610,21 +1650,21 @@ { \figurename\space #1 \notbool{eb@titletoc@hang@fix} - {\hspace{\eb@toc@list@numsep}}{} + {\hspace{\eb@toc@figure@numsep}}{} }, tocline-tab .cs_set:Np = \eb@labelname@lot #1, tocline-tab .initial:n = { \tablename\space #1 \notbool{eb@titletoc@hang@fix} - {\hspace{\eb@toc@list@numsep}}{} + {\hspace{\eb@toc@table@numsep}}{} }, tocline-lst .tl_set:N = \eb@labelname@lol, tocline-lst .initial:n = { \lstlistingname\space\thelstlisting \notbool{eb@titletoc@hang@fix} - {\hspace{\eb@toc@list@numsep}}{} + {\hspace{\eb@toc@lstlisting@numsep}}{} }, line-align .bool_set:N = \l__eb_toc_line_align_bool, line-align .default:n = true, @@ -1679,6 +1719,18 @@ list/rule = #1 } } + +\NewDocumentCommand{\tocrule}{sO{0.7pc}D(){1.2}mO{}} + { + \normalsize\normalfont + \titlerule*[#2]{\scalebox{#3}{#4}}#5 + \IfBooleanTF{#1} + {\thecontentspage} + { + \bool_if:NTF \l__eb_toc_line_align_bool + { \contentspage } { \thecontentspage } + } + } \ctex_set:nn { tocset } { part/format = \addvspace{1pc}\sffamily\large, @@ -1699,53 +1751,12 @@ { \bool_if:NTF \l__eb_class_book_bool { 3.8\ccwd } { 1.4\ccwd } }, subsection/rule = \tocrule{$\cdot$}, - list/format = \addvspace{0.2pc}, - list/indent = 0\ccwd, - list/rule = \tocrule{$\cdot$} - } - -\NewDocumentCommand{\tocrule}{sO{0.7pc}D(){1.2}mO{}} - { - \normalsize\normalfont - \titlerule*[#2]{\scalebox{#3}{#4}}#5 - \IfBooleanTF{#1} - {\thecontentspage} - { - \bool_if:NTF \l__eb_toc_line_align_bool - { \contentspage } { \thecontentspage } - } - } -\cs_new_protected:Npn \eb_titlecontents_set:nn #1#2 - { - \titlecontents{#1} - [\use:c { l__eb_toc_#2_indent_tl }] - {\use:c { l__eb_toc_#2_format_tl }} - { - \ifbool{eb@titletoc@hang@fix} - { - \contentspush - { - \bool_if:NT \l__eb_toc_number_color_bool - { \color{ctex@toc@number} } - \thecontentslabel - \hspace{\use:c { eb@toc@#2@numsep }} - } - }{} - }{} - {\use:c { l__eb_toc_#2_rule_tl }} - } -\contentsuse{lstlisting}{lol} -\clist_map_inline:nn - { - { part } { part }, - { chapter } { chapter }, - { section } { section }, - { subsection } { subsection }, - { figure } { list }, - { table } { list }, - { lstlisting } { list } + list/format = \addvspace{0.2pc}, + list/indent = 0\ccwd, + list/rule = \tocrule{$\cdot$}, + list/belowoffset = + { \bool_if:NTF \l__eb_class_book_bool { 0pc } { 0.15pc } } } - { \eb_titlecontents_set:nn #1 } \prop_new:N \l__eb_label_name_prop \prop_set_from_keyval:Nn \l__eb_label_name_prop @@ -1962,7 +1973,7 @@ \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} \eb_multoc_pre_bool: \eb_title_number_intoc_bool:nn {#2} {#1} - \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_listoffset_dim + \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_figure_offset_dim \vspace*{\dim_use:N \l__eb_toc_offset_dim} \@starttoc{lof} \eb_multoc_post_bool: @@ -1975,7 +1986,7 @@ \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} \eb_multoc_pre_bool: \eb_title_number_intoc_bool:nn {#2} {#1} - \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_listoffset_dim + \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_table_offset_dim \vspace*{\dim_use:N \l__eb_toc_offset_dim} \@starttoc{lot} \eb_multoc_post_bool: @@ -1988,7 +1999,7 @@ \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} \eb_multoc_pre_bool: \eb_title_number_intoc_bool:nn {#2} {#1} - \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_listoffset_dim + \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_lstlisting_offset_dim \vspace*{\dim_use:N \l__eb_toc_offset_dim} \@starttoc{lol} \eb_multoc_post_bool: @@ -2754,16 +2765,16 @@ \bool_set_false:N \l__eb_toc_number_color_bool \eb_ctex_define:nn { refset } { - hyperlink .choice:, - hyperlink/edge .code:n = { }, - hyperlink/none .code:n = \eb_put_hyperref:n { hidelinks }, - hyperlink/various .code:n = + linktype .choice:, + linktype/edge .code:n = { }, + linktype/none .code:n = \eb_put_hyperref:n { hidelinks }, + linktype/various .code:n = { \bool_set_true:N \l__eb_toc_number_color_bool \eb_put_hyperref:n { colorlinks } }, - hyperlink .default:n = edge, - hyperlink .initial:n = edge, + linktype .value_required:n = true, + linktype .initial:n = edge, linktoc .choice:, linktoc/unknown .code:n = @@ -2778,9 +2789,9 @@ } } }, - linktoc .default:n = all, - linktoc .initial:n = all, - unknown .code:n = + linktoc .default:n = all, + linktoc .initial:n = all, + unknown .code:n = { \eb_put_hyperref:x { diff --git a/macros/latex/contrib/easybook/easybook.pdf b/macros/latex/contrib/easybook/easybook.pdf Binary files differindex 380806bafd..b2fcc357ab 100644 --- a/macros/latex/contrib/easybook/easybook.pdf +++ b/macros/latex/contrib/easybook/easybook.pdf diff --git a/macros/latex/contrib/noindentafter/README b/macros/latex/contrib/noindentafter/README deleted file mode 100644 index 1eb4449dbf..0000000000 --- a/macros/latex/contrib/noindentafter/README +++ /dev/null @@ -1,50 +0,0 @@ -latex-noindentafter -=============== - -LaTeX Package : noindentafter 0.2.2 - -Last Modified : 2014/11/30 - -Author : Michiel Helvensteijn (www.mhelvens.net) - - -Summary -------- - -This package, as the name suggests, supplies tools to automatically -suppress indentation in paragraphs, specifically those following -particular macros or environments. - - -Prerequisites -------------- - -To use this package, you need only `etoolbox`, though to generate -the documentation some other packages are needed. - - -Installation -------------- - -`noindentafter.sty` is provided directly in the package archive. -Put it in a place where your LaTeX distribution can find it. -(`noindentafter.sty` is not generated, but manually maintained; - you may use docstrip to remove the documentation, but you don't - have to; it will just work the way it is) - - -Documentation -------------- -`noindentafter.pdf` is provided directly in the package archive. -To generate the documentation yourself, run LaTeX on `noindentafter.tex`. -(`noindentafter.tex` does not contain the package code itself; it inputs - `noindentafter.sty` directly to document the implementation) - - -License -------- - -This material is subject to the LaTeX Project Public License. See -http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html -for the details of that license. - diff --git a/macros/latex/contrib/noindentafter/README.md b/macros/latex/contrib/noindentafter/README.md new file mode 100644 index 0000000000..bee02a49cc --- /dev/null +++ b/macros/latex/contrib/noindentafter/README.md @@ -0,0 +1,41 @@ + + noindentafter – purposefully prevention of paragraph indentation +------------------------------------------------------------------------------- + + Copyright (C) Michiel Helvensteijn, 2014-2021<br> + Copyright (C) Falk Hanisch <hanisch.latex@outlook.com>, 2021-2021 + + **noindentafter 2021-05-14 v1.00** + + The current release is shiped via CTAN: https://www.ctan.org/pkg/noindentafter + +------------------------------------------------------------------------------- + + This material is subject to the LaTeX Project Public License version 1.3c + or later. See http://www.latex-project.org/lppl.txt for details. + +------------------------------------------------------------------------------- + + +Summary +------- + +The **noindentafter** package, as the name suggests, supplies functionallity to +purposefully prevent indentation of paragraphs, specifically those following +particular macros or environments in an automated manner. To use this package, +only packages `etoolbox` and `xpatch` are required. + + +Versions +-------- +**v1.00** (2021-05-14) ++ new maintainer: Falk Hanisch ++ fix for `LaTeXe 2019-10-01` and later + +**v0.2.0** (2014-11-30) ++ new implementation, fixing a spacing issue + +**v0.0.1** (2013-08-02) ++ initial version by Michiel Helvensteijn + + diff --git a/macros/latex/contrib/noindentafter/doc/LICENSE.md b/macros/latex/contrib/noindentafter/doc/LICENSE.md new file mode 100644 index 0000000000..de6e53039e --- /dev/null +++ b/macros/latex/contrib/noindentafter/doc/LICENSE.md @@ -0,0 +1,21 @@ + + noindentafter – purposefully prevention of paragraph indentation +---------------------------------------------------------------------------- + + Copyright (C) Michiel Helvensteijn, 2014-2021<br> + Copyright (C) Falk Hanisch <hanisch.latex@outlook.com>, 2021-2021 + +---------------------------------------------------------------------------- + + This work may be distributed and/or modified under the conditions of the + LaTeX Project Public License, version 1.3c of the license. The latest + version of this license is in<br> + http://www.latex-project.org/lppl.txt<br> + and version 1.3c or later is part of all distributions of + LaTeX version 2008-05-04 or later. + + This work has the LPPL maintenance status "author-maintained". + + The current maintainer and author of this work is Falk Hanisch. + +---------------------------------------------------------------------------- diff --git a/macros/latex/contrib/noindentafter/doc/noindentafter.pdf b/macros/latex/contrib/noindentafter/doc/noindentafter.pdf Binary files differnew file mode 100644 index 0000000000..3f332ad399 --- /dev/null +++ b/macros/latex/contrib/noindentafter/doc/noindentafter.pdf diff --git a/macros/latex/contrib/noindentafter/noindentafter-dry.sty b/macros/latex/contrib/noindentafter/noindentafter-dry.sty deleted file mode 100644 index 27ba1a3077..0000000000 --- a/macros/latex/contrib/noindentafter/noindentafter-dry.sty +++ /dev/null @@ -1,54 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \iffalse %%%% -% % -% Copyright (c) 2014 - Michiel Helvensteijn - www.mhelvens.net % -% % -% https://github.com/mhelvens/latex-delta-modules % -% % -% This work may be distributed and/or modified under the conditions % -% 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 distributions of LaTeX % -% version 2005/12/01 or later. % -% % -% This work has the LPPL maintenance status 'maintained'. % -% % -% The Current Maintainer of this work is Michiel Helvensteijn. % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%% - -% I will 'officially' release this file at some point in the future. For -% now I'm just using it to document a couple of packages. Still, it's -% released under LPPL, so use it as you will. -% -% -- Michiel Helvensteijn - -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{noindentafter-dry} - [2013/10/11 convenience macros for reusing LaTeX code] - -\RequirePackage{filecontents} -\RequirePackage{xparse} -\RequirePackage{etoolbox} -\RequirePackage{withargs} - -\newcommand\minput[1]{% - \input{#1}\unskip% -} - -\NewDocumentCommand{\NewDRYer}{m +m}{% - \withargs [\uniquecsname] [#2] {% - \newenvironment{#1}{% - \begingroup% - \@tempswafalse\filec@ntents{##1.tmp}% - }{% - \endfilecontents% - \endgroup% - }% - \AfterEndEnvironment{#1}{% - \withargs (xn) [##1.tmp] [\minput{##1.tmp}] {% - ##2% - }% - }% - }% -} diff --git a/macros/latex/contrib/noindentafter/noindentafter-packagedoc.cls b/macros/latex/contrib/noindentafter/noindentafter-packagedoc.cls deleted file mode 100644 index 1eb80d548c..0000000000 --- a/macros/latex/contrib/noindentafter/noindentafter-packagedoc.cls +++ /dev/null @@ -1,313 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% Copyright (C) 2012-2013 by Michiel Helvensteijn - www.mhelvens.net % -% % -% This work may be distributed and/or modified under the % -% conditions 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 distributions of % -% LaTeX version 2005/12/01 or later. % -% % -% This work has the LPPL maintenance status `author-maintained'. % -% % -% The Current Maintainer of this work is Michiel Helvensteijn. % -% % -% This work consists of the file packagedoc.cls. % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\let\packagename\jobname - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Document Class % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\LoadClassWithOptions{ltxdoc} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Importing The Relevant Package % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\RequirePackage{\packagename} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Importing Other Packages % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -\RequirePackage[hyphens]{url} - -\RequirePackage{etoolbox} -\RequirePackage[xcolor]{mdframed} -\RequirePackage{marginnote} -\RequirePackage{listings} -\RequirePackage{textcomp} -\RequirePackage[colorlinks=true]{hyperref} -\RequirePackage{noindentafter-dry} -\RequirePackage{needspace} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Documentation Options % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\EnableCrossrefs -\CodelineIndex -\RecordChanges - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% File Info % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\GetFileInfo{\packagename.sty} - -\title{The \textsf{\packagename} package\thanks{% - This document corresponds to \textsf{\packagename}~\fileversion, - dated \filedate.% -}} - -\author{ - Michiel Helvensteijn\\ - \href{mailto:mhelvens+latex@gmail.com}{mhelvens+latex@gmail.com} -} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Development Info % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\newmdenv[ - leftline = false, - rightline = false -]{bannerframe} - -\apptocmd{\maketitle}{ - \begin{bannerframe} - \small - \begin{center} - Development of this package is organized at - \href{http://latex-\packagename.googlecode.com} - {latex-\packagename.googlecode.com}.\\ - I am happy to receive feedback there! - \end{center} - \end{bannerframe} -}{}{} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Example Environment Setup % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% Extra keywords for LaTeX -% -\newcommand{\moretexcs}[1]{ - \lstdefinelanguage{latex}{ - language=[LaTeX]tex, - alsoletter={\[,\],\$}, - moretexcs={ExplSyntaxOn,ExplSyntaxOff,lstinputlisting,detokenize,[,],#1}, - keywords={\$} - } -} - -%%% Code formatting -% -\lstdefinestyle{examplecode}{% - language=latex,% - basicstyle=\ttfamily\small,% - texcsstyle=*\bfseries,% - keywordstyle=*\bfseries,% - upquote=true% -} - -%%% Setting up example code block -% -\definecolor{examplecodelinecolor}{rgb}{0,0,0} -\definecolor{examplecodebackgroundcolor}{rgb}{.9,.9,.9} -\newmdenv[ - linecolor = examplecodelinecolor, - backgroundcolor = examplecodebackgroundcolor, - skipabove = 0pt, - skipbelow = 0pt, - innertopmargin = -1pt, - innerrightmargin = 1pt, - innerbottommargin = -1pt, - innerleftmargin = 1pt -]{examplecodeframe} - -%%% Defining example output block -% -\definecolor{exampleoutputbackgroundcolor}{rgb}{1,1,1} -\newmdenv[ - linecolor = examplecodelinecolor, - backgroundcolor = exampleoutputbackgroundcolor, - skipabove = 0pt, - skipbelow = 0pt, - innertopmargin = 6pt, - innerrightmargin = 6pt, - innerbottommargin = 6pt, - innerleftmargin = 6pt, - nobreak = true -]{exampleoutputframe} - -%%% Macros for counting lines in file, adapted from -%%% http://andreas.scherbaum.la/blog/archives/ -%%% 670-Read-number-lines-in-a-file-in-LaTeX.html -% -\RequirePackage{ifthen} -\newboolean{packagedoc@restfile} -\newcommand*{\packagedoc@fileline}{} -\newread\packagedoc@file -\newcommand*{\packagedoc@readnextline}[1]{% - \ifthenelse{\boolean{packagedoc@restfile}}{% - \read#1 to \packagedoc@fileline% - \ifeof#1\setboolean{packagedoc@restfile}{false}% - \else\fi% - }{}% -} -\newcommand*{\countlinesinfile}[2]{% - \setboolean{packagedoc@restfile}{true}% - \setcounter{packagedoc@linecount}{0}% - \openin\packagedoc@file=#1% - \whiledo{\boolean{packagedoc@restfile}}{% - \packagedoc@readnextline{\packagedoc@file}% - \ifthenelse{\boolean{packagedoc@restfile}}{% - \stepcounter{packagedoc@linecount}% - }{}% - }% - \closein\packagedoc@file% - \edef#2{\thepackagedoc@linecount}% -} - -\newcounter{packagedoc@linecount} -\newlength{\packagedoc@spacetoreserve} - -%%% DRYer without output -% -\NewDRYer{latex-example}{% - \vskip\abovedisplayskip% - {% - \ttfamily\small% - \countlinesinfile{#1}{\countedlines}% - \setlength{\packagedoc@spacetoreserve}{\countedlines\baselineskip}% - \addtolength{\packagedoc@spacetoreserve}{-1pt}% - \needspace{\packagedoc@spacetoreserve}% - }% - \begin{examplecodeframe}% - \renewcommand{\ttdefault}{pcr}% - \lstinputlisting[style=examplecode]{#1}% - \end{examplecodeframe}% - #2% - \vskip\belowdisplayskip% -} - -%%% DRYer WITH output but WITHOUT side-effects -% -\NewDRYer{latex-example-show}{% - \vskip\abovedisplayskip% - {% - \ttfamily\small% - \countlinesinfile{#1}{\countedlines}% - \setlength{\packagedoc@spacetoreserve}{\countedlines\baselineskip}% - \addtolength{\packagedoc@spacetoreserve}{\baselineskip}% - \needspace{\packagedoc@spacetoreserve}% - }% - \begin{examplecodeframe}% - \renewcommand{\ttdefault}{pcr}% - \lstinputlisting[style=examplecode]{#1}% - \end{examplecodeframe}\vspace{-1pt}% - \begin{exampleoutputframe}% - #2% - \end{exampleoutputframe}% - \vskip\belowdisplayskip% -} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Implementation Code Box Setup % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% Saving old implementation code block font -% -\AtBeginDocument{\let\old@macro@font\macro@font} - -%%% Setup for 'interesting' implementation code blocks -% -\definecolor{interestingcodebackgroundcolor}{rgb}{.9,.9,.9} -\definecolor{interestingcodelinecolor}{rgb}{0,0,0} -\mdfdefinestyle{interestingcode}{ - linecolor = interestingcodelinecolor, - backgroundcolor = interestingcodebackgroundcolor -} -\newcommand*{\interesting}{% - \def\codestyle{interestingcode}% - \def\codeskipabove{2pt}% - \let\macro@font\old@macro@font% -} - -%%% Setup for 'UNinteresting' implementation code blocks -% -\definecolor{uninterestingcodebackgroundcolor}{rgb}{.97,.97,.97} -\definecolor{uninterestingcodelinecolor}{rgb}{.5,.5,.5} -\definecolor{uninterestingcodecolor}{rgb}{.4,.4,.4} -\mdfdefinestyle{uninterestingcode}{ - linecolor = uninterestingcodelinecolor, - backgroundcolor = uninterestingcodebackgroundcolor, -} -\newcommand*{\uninteresting}{% - \def\codestyle{uninterestingcode}% - \def\codeskipabove{-2pt}% - \def\macro@font{\color{uninterestingcodecolor}\old@macro@font}% -} - -%%% Actually surround 'macrocode' with the frame -% -\surroundwithmdframed[ - style = \codestyle, - skipabove = \abovedisplayskip, - skipbelow = \belowdisplayskip, - splittopskip = 4pt, - splitbottomskip = 1pt, - innertopmargin = -2pt, - innerrightmargin = 1pt, - innerbottommargin = 5pt, - innerleftmargin = 4pt -]{macrocode} - -%%% Start out with 'interesting' code status and -%%% always go back to it after one code block -% -\interesting -\AfterEndEnvironment{macrocode}{\interesting} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Argument Specifiers and such % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\newcommand*{\movarg}[1]{[ \texttt{#1} ]} -\newcommand*{\momarg}[1]{[ \meta{#1} ]} - -\newcommand{\describemacro}[2]{% - \needspace{3\baselineskip}% - \noindent\\\DescribeMacro{#1} #2\\% -} - -\newcommand{\describemetamacro}[2]{% - \needspace{3\baselineskip}% - \noindent\\\marginnote{\meta{#1}} #2\\% -} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Automatic Implementation Docs % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\AtEndDocument{ - \section{Implementation} - - \StopEventually {\PrintChanges} - - We now show and explain the entire implementation from \texttt{\packagename.sty}. - - \DocInput{\packagename.sty} - - \Finale - - \PrintIndex -} diff --git a/macros/latex/contrib/noindentafter/noindentafter.pdf b/macros/latex/contrib/noindentafter/noindentafter.pdf Binary files differdeleted file mode 100644 index b8d1d8aad1..0000000000 --- a/macros/latex/contrib/noindentafter/noindentafter.pdf +++ /dev/null diff --git a/macros/latex/contrib/noindentafter/noindentafter.sty b/macros/latex/contrib/noindentafter/noindentafter.sty deleted file mode 100644 index 2ea6e22b37..0000000000 --- a/macros/latex/contrib/noindentafter/noindentafter.sty +++ /dev/null @@ -1,189 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \iffalse %%%% -% % -% Copyright (c) 2014 - Michiel Helvensteijn - www.mhelvens.net % -% % -% http://latex-noindentafter.googlecode.com % -% % -% This work may be distributed and/or modified under the conditions % -% 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 distributions of LaTeX % -% version 2005/12/01 or later. % -% % -% This work has the LPPL maintenance status `maintained'. % -% % -% The Current Maintainer of this work is Michiel Helvensteijn. % -% % -% This work consists of the files noindentafter.tex and noindentafter.sty. % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%% - -% \CheckSum{50} -% -% \CharacterTable -% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z -% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z -% Digits \0\1\2\3\4\5\6\7\8\9 -% Exclamation \! Double quote \" Hash (number) \# -% Dollar \$ Percent \% Ampersand \& -% Acute accent \' Left paren \( Right paren \) -% Asterisk \* Plus \+ Comma \, -% Minus \- Point \. Solidus \/ -% Colon \: Semicolon \; Less than \< -% Equals \= Greater than \> Question mark \? -% Commercial at \@ Left bracket \[ Backslash \\ -% Right bracket \] Circumflex \^ Underscore \_ -% Grave accent \` Left brace \{ Vertical bar \| -% Right brace \} Tilde \~} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \subsection{Package Info} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% \begin{macrocode} -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{noindentafter}[2014/11/30 0.2.2 - prevent paragraph indentation after specific environments or macros] -% \end{macrocode} -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \subsection{Packages} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% \begin{macrocode} -\RequirePackage{etoolbox} -% \end{macrocode} -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \subsection{Patches} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% \needspace{5\baselineskip}\begin{macro}{\end} -% -% The package |etoolbox| provides the command -% |\AfterEndEnvironment| which creates a hook executed at a -% very late point inside the |\end| command. However, this -% hook is still located before |\ignorespaces|, which is -% too early to properly suppress the indention after an -% environment. Therefore another hook is now added to |\end| -% using |\patchcmd|. This new hook puts new code at the very -% end. -% -% \begin{macrocode} -\patchcmd\end{% - \if@ignore\@ignorefalse\ignorespaces\fi% -}{% - \if@ignore\@ignorefalse\ignorespaces\fi% - \csuse{@noindent@#1@hook}% -}{}{% - \PackageWarningNoLine{noindentafter}{% - Patching `\string\end' failed!\MessageBreak% - `\string\NoIndentAfter...' commands won't work% - }% -} -% \end{macrocode} -% -%\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \subsection{Macros} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% \needspace{5\baselineskip}\begin{macro}{\@NoIndentAfter} -% -% \noindent This command implements the main principle -% behind this package. It checks whether it is followed by -% a paragraph. If so, the command |\par| is temporarily -% changed using |\everypar|, so that the following paragraph -% is not indented. Immediately afterwards, default paragraph -% behavior is restored with |\@restorepar| (from the \LaTeX{} -% base). -% -% \begin{macrocode} -\newcommand*\@NoIndentAfter{% - \@ifnextchar\par{% - \def\par{% - \everypar{\setbox\z@\lastbox\everypar{}}% - \@restorepar% - }% - }{}% -} -% \end{macrocode} -% -%\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% \needspace{5\baselineskip}\begin{macro}{\NoIndentAfterThis} -% -% \noindent Enforce a paragraph break and suppress -% indentation for whatever follows. -% -% \begin{macrocode} -\newrobustcmd*{\NoIndentAfterThis}{\@NoIndentAfter\par\par} -% \end{macrocode} -% -%\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % \needspace{5\baselineskip}\begin{macro}{\NoIndentAfterEnv} -%%% \marg{environment}\\ -% -% \noindent Append |\@NoIndentAfter| to the output of -% \meta{environment} by using the new environment hook. -% -% \begin{macrocode} -\newrobustcmd{\NoIndentAfterEnv}[1]{% - \csdef{@noindent@#1@hook}{\@NoIndentAfter}% -} -% \end{macrocode} -% -%\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % \needspace{5\baselineskip}\begin{macro}{\NoIndentAfterCmd} -%%% \marg{command}\\ -% -% \noindent Append |\NoIndentAfterThis| to the output of -% \meta{command}. -% -% \begin{macrocode} -\newrobustcmd*{\NoIndentAfterCmd}[1]{% - \apptocmd{#1}{\NoIndentAfterThis}{}{% - \PackageWarning{noindentafter}{% - Patching `\string#1' failed!\MessageBreak% - `\string\NoIndentAfterCmd' won't work% - }% - }% -} -% \end{macrocode} -% -%\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - diff --git a/macros/latex/contrib/noindentafter/noindentafter.tex b/macros/latex/contrib/noindentafter/noindentafter.tex deleted file mode 100644 index 6aac2ebe06..0000000000 --- a/macros/latex/contrib/noindentafter/noindentafter.tex +++ /dev/null @@ -1,205 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% Copyright (c) 2014 - Michiel Helvensteijn - www.mhelvens.net % -% % -% http://latex-noindentafter.googlecode.com % -% % -% This work may be distributed and/or modified under the % -% conditions 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 distributions of % -% LaTeX version 2005/12/01 or later. % -% % -% This work has the LPPL maintenance status `maintained'. % -% % -% The Current Maintainer of this work is Michiel Helvensteijn. % -% % -% This work consists of the files noindentafter.tex and noindentafter.sty. % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\documentclass[a4paper]{noindentafter-packagedoc} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Setup % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\NoIndentAfterEnv{latex-example-show} -\NoIndentAfterCmd{\describemacro} - -\moretexcs{% - NoIndentAfterThis,NoIndentAfterEnv,NoIndentAfterCmd -} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Global Changes % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\changes{0.0.1}{2013/08/02} - {initial version} -\changes{0.2.0}{2014/11/30} - {new implementation, fixing a spacing issue} -\changes{0.2.2}{2014/11/30} - {fixed version number in the README} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{document} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\maketitle - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Introduction} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -Some people prefer certain LaTeX environments ---such as |itemize| or -|theorem|--- never to be followed by an indented paragraph. It is of course -possible to manually add the |\noindent| command to each occurrence, but -it's easy to forget to do this. Also, all those |\noindent| commands leave -your \TeX{} code just a little bit more chaotic and more burdensome to read. - -There are a number of solutions floating around, but many of them are not -particularly robust, or only work in specific cases. - -The |noindentafter| package provides a few simple commands which can be used -to patch existing macros and environments. They work as expected in all cases -I've encountered. - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Usage} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\noindent\DescribeMacro{\NoIndentAfterThis} -% -This is the most primitive macro offered by the package. It forces a -paragraph break and suppresses indentation for whatever follows: - -\begin{latex-example-show} - Lorem ipsum dolor sit amet, consectetur adipiscing - elit. \NoIndentAfterThis Pellentesque hendrerit volutpat - feugiat. Ut purus leo, pulvinar sit amet vehicula non, - pulvinar eu lacus. Curabitur id mollis ligula. -\end{latex-example-show} - - - -\pagebreak % Hack to make the footnote appear on page 1. - - - -\describemacro{\NoIndentAfterEnv}{\marg{environment}} - -This is probably the command most people will want to use. -The \meta{environment} argument should contain an environment -name. After using this command, any paragraph following such -an environment will remain unindented. - -\begin{latex-example-show} - Lorem ipsum dolor sit amet, consectetur adipiscing elit. - - \begin{itemize} - \item First Item - \item Second Item - \end{itemize} - - Pellentesque hendrerit volutpat feugiat. Ut purus - leo, pulvinar sit amet vehicula non, pulvinar eu - lacus. Curabitur id mollis ligula. - - \NoIndentAfterEnv{itemize} - - Vestibulum id erat venenatis, facilisis enim non, - consectetur felis. Quisque iaculis eu arcu non pretium. - - \begin{itemize} - \item Third Item - \item Fourth Item - \end{itemize} - - Curabitur est elit, posuere pulvinar laoreet sed, varius - id mi. Nam lobortis elit nec mauris condimentum gravida. -\end{latex-example-show} - -You'll probably want to use these commands in the document -preamble but, as you can see, you don't really have to. - -\needspace{10\baselineskip} -Note that using the |\NoIndentAfterEnv| command on your own -environment is not the same as adding |\NoIndentAfterThis| -to the end of it: - -\begin{latex-example-show} - \newenvironment{test}{\itshape}{\NoIndentAfterThis} - - \begin{test} - Lorem ipsum dolor sit amet, consectetur - adipiscing elit. - \end{test} - - Pellentesque hendrerit volutpat feugiat. Ut purus - leo, pulvinar sit amet vehicula non, pulvinar eu - lacus. Curabitur id mollis ligula. -\end{latex-example-show} - -|\NoIndentAfterEnv| works because it bypasses the group -that surrounds every \LaTeX{} environment (and localizes -declarations). - - - -\describemacro{\NoIndentAfterCmd}{\marg{command}} - -Finally, you may also patch command sequences using the -|\NoIndentAfterCmd| command. There may not be many situations -where this is useful, but for me, there is at least one: - -\begin{latex-example-show} - Lorem ipsum dolor sit amet, consectetur adipiscing elit: - - \[ 1 + 1 = 2 \] - - Pellentesque hendrerit volutpat feugiat. Ut purus leo: - - \NoIndentAfterCmd \] - - \[ 2 + 2 = 4 \] - - Vestibulum id erat venenatis, facilisis enim non, - consectetur felis. -\end{latex-example-show} - -Note that braces around the \meta{command} argument are -optional, as always when an argument in \TeX{} consists -of only a single token. - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Acknowledgements} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -I had been looking for a solution like this for quite a while. I came up -with a number of hacks that workedin some situations but not in others. -Eventually I asked a question on \url{http://tex.stackexchange.com}: -\begin{itemize} - \item \url{http://tex.stackexchange.com/questions/112404} -\end{itemize} - -I received two excellent answers -- one from cgnieder and one from lockstep. -This package was originally based on the technique proposed by cgnieder, as -it is simpler and more generally applicable. Still, the answer by lockstep -is definitely worth a read. - -Most recently, a better approach was implemented by tudscr to fix the spacing -above headers: -\begin{itemize} - \item \url{https://github.com/mhelvens/latex-noindentafter/pull/1} -\end{itemize} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\end{document} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/macros/latex/contrib/noindentafter/source/noindentafter.dtx b/macros/latex/contrib/noindentafter/source/noindentafter.dtx new file mode 100644 index 0000000000..4b86ee68c7 --- /dev/null +++ b/macros/latex/contrib/noindentafter/source/noindentafter.dtx @@ -0,0 +1,407 @@ +% \iffalse meta-comment +% noindentafter.dtx +%<*identify> +% +% noindentafter -- purposefully prevention of paragraph indentation +% +%% ---------------------------------------------------------------------------- +%% +%% Copyright (C) Michiel Helvensteijn, 2014-2021 +%% Copyright (C) Falk Hanisch <hanisch.latex@outlook.com>, 2021-2021 +%% +%% ---------------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License, version 1.3c of the license. The latest +%% version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of +%% LaTeX version 2008-05-04 or later. +%% +%% This work has the LPPL maintenance status "author-maintained". +%% +%% The current maintainer and author of this work is Falk Hanisch. +%% +%% This work consists of the main source file README.md, LICENSE.md, +%% noindentafter.dtx and the derived documentation noindentafter.pdf +%% +%% ---------------------------------------------------------------------------- +%% +%</identify> +% \fi +% +% \iffalse +%<*dtx> +\ifx\documentclass\undefined +\input docstrip.tex +\keepsilent + +\preamble + +noindentafter -- purposefully prevention of paragraph indentation + +\endpreamble +\askforoverwritefalse +\usedir{tex/latex/noindentafter} +\generate{% + \usepreamble\defaultpreamble + \file{noindentafter.sty}{ + \from{noindentafter.dtx}{package,identify} + \from{noindentafter.dtx}{package,body} + } +} +\else +\let\endbatchfile\relax +\fi +\endbatchfile +%</dtx> +% \fi +% +% \iffalse +%<*dtx|package&identify> +\NeedsTeXFormat{LaTeX2e}[2020-10-01] +%<*dtx> +\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi +\ProvidesFile{noindentafter.dtx} +%</dtx> +%<package&identify>\ProvidesPackage{noindentafter} + [2021-05-14 v1.00 purposefully prevention of paragraph indentation] +%</dtx|package&identify> +% \fi +% +% \iffalse +%<*dtx> +\documentclass[english,xindy]{tudscrdoc} +\KOMAoptions{parskip=false} +\usepackage{iftex} +\iftutex + \usepackage{fontspec} +\else + \usepackage[T1]{fontenc} +\fi +\usepackage{babel} +% normalized vskip for listings +\newlength\niavskip +\AtBeginDocument{% + \ifdim\parskip>\bigskipamount% + \setlength\niavskip{\parskip}% + \else% + \setlength\niavskip{\bigskipamount}% + \fi% +} +\newcommand*\nianormalizedvskip{\vskip\glueexpr\niavskip-\parskip\relax} +% listings style +\usepackage{xcolor} +\usepackage{quoting} +\usepackage{listings} +\lstset{% + inputencoding=utf8,extendedchars=true,% + literate=% + {ä}{{\"a}}1 {ö}{{\"o}}1 {ü}{{\"u}}1 + {Ä}{{\"A}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 + {ß}{{\ss}}1 {~}{{\textasciitilde}}1 + {»}{{\guillemetright}}1 {«}{{\guillemetleft}}1 +} +\lstdefinestyle{noindentafter}{% + language=[LaTeX]tex,% + columns=flexible,% + frame=single,% + xleftmargin=\fboxsep,% + xrightmargin=\fboxsep,% + escapechar=§,% + aboveskip=\niavskip,% + belowskip=0pt,% + backgroundcolor=\color{yellow!10},% + basicstyle=\color{darkgray}\small\ttfamily,% + moretexcs=[2]{NoIndentAfterThis,NoIndentAfterCmd,NoIndentAfterEnv},% + texcsstyle=*\color{black},% + texcsstyle=*[2]\color{red}\bfseries,% +} +\lstnewenvironment{niaexample}[1][]{% + \lstset{style=noindentafter,#1}% +}{% + \nianormalizedvskip% +} +\makeatletter +% suppress overwriting warning +\providecommand*\filec@ntents@silent{% + \let\@latex@warning@no@line\@gobble% +} +% environment for listing and inclusion, unused guard <manual> necessary +\newenvironment{niashow}{% + \csuse{filecontents*}[force,nosearch,silent]{\jobname-lst.aux}% +}{% + \csuse{endfilecontents*}% +}% +\AfterEndEnvironment{niashow}{% + \begin{quoting}[rightmargin=0pt,vskip=0pt] + \lstinputlisting[style=noindentafter]{\jobname-lst.aux}% + \nianormalizedvskip% + \input{\jobname-lst.aux}% + \nianormalizedvskip% + \end{quoting}% +} +\newcommand*\niaagain[1][\relax]{% + #1% + \begin{quoting}[rightmargin=0pt,vskip=0pt] + \nianormalizedvskip% + \input{\jobname-lst.aux}% + \nianormalizedvskip% + \end{quoting}% +} +% TODO l3doc + l3build +\NewDocumentCommand\DescribeMacroExtended{m !o}{% + \ifhmode% + \vskip\niavskip% + \else% + \addpenalty{\@beginparpenalty}% + \addvspace{\niavskip}% + \fi% + \noindent% + \DescribeMacro{#1}% + \IfValueT{#2}{% + \expandafter\cs\expandafter{\expandafter\@gobble\string#1}#2% + \vskip\smallskipamount% + }% + \noindent\ignorespaces% +} +\makeatother + +\usepackage{bookmark} +\usepackage[babel]{microtype} + +\usepackage{noindentafter} +\NoIndentAfterEnv{niaexample} +\NoIndentAfterEnv{niashow} +\NoIndentAfterCmd{\niaagain} + + +%\EnableCrossrefs +\CodelineIndex +\RecordChanges +\GetFileInfo{noindentafter.dtx} + + + +\begin{document} + \title{The package \pkg{noindentafter}} + \author{% + Michiel Helvensteijn (2014-2021)\\% + Falk Hanisch (2021--)\\% + \url{https://github.com/mrpiggi/noindentafter}\\% + \mailto{hanisch.latex@outlook.com}% + } + \date{\fileversion\nobreakspace(\filedate)} + \maketitle% + \begin{abstract} + \noindent + For certain environments---such as \env{itemize} or \env{theorem}---as + well as specific commands, indentation of the following paragraph is not + desired. It is of course possible to manually add \cs{noindent} to each + occurrence, but it is very easy to forget this at one point or another. + This package provides a few simple commands which can be used to patch + existing macros and environments in order to get rid of manually using + \cs{noindent} after these. Therefore, both packages \pkg{etoolbox} and + \pkg{xpatch} are required. + \end{abstract} + %\tableofcontents + \setcounter{secnumdepth}{0} + \DocInput{\filename} +\end{document} +% \fi +% +\changes{v0.0.1}{2013-08-02}{initial version by Michiel Helvensteijn} +\changes{v0.2.0}{2014-11-30}{new implementation, fixing a spacing issue} +\changes{v0.2.2}{2014-11-30}{fixed version number in the README} +\changes{v1.00}{2021-05-11}{new maintainer: Falk Hanisch}^^A +\changes{v1.00}{2021-05-14}{fix for \LaTeXe\ 2019-10-01 and later} + + + +\section{Usage} + +The package does not provide additional options and is used in the simplest way +possible: + +\begin{niaexample} +\usepackage{noindentafter} +\end{niaexample} + +In order to ensure a consistent layout throughout the document, it is +recommended---but not mandatory---to use the commands described below within +the preamble after loading package \pkg{noindentafter}. + + + +\DescribeMacroExtended{\NoIndentAfterEnv}[\marg{environment}] +This is probably the most frequently needed functionality. After using this +command, any paragraph following such an \marg{environment} will remain +unindented. The example below shows the default output without the involvement +of \pkg{noindentafter}. + +\begin{niashow} +Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, +vestibulum ut, placerat ac, adipiscing vitae, felis. + +\begin{itemize} + \item First Item + \item Second Item +\end{itemize} + +Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer +id, vulputate a, magna. Donec vehicula augue eu neque. + +Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac +turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. +\end{niashow} + +Once \lstinline[style=noindentafter]|\NoIndentAfterEnv{itemize}| has been +executed, the output differs by the \emph{unintended} paragraph directly after +the \env{itemize} environment: \niaagain[\NoIndentAfterEnv{itemize}] + +Note that using the \cs{NoIndentAfterEnv} command on an environment is not the +same as adding \cs{NoIndentAfterThis} to the end of it:^^A +\footnote{\cs{NoIndentAfterEnv} bypasses the group that surrounds environments} + +\begin{niashow} +\newenvironment{mytestenv}{\itshape}{\NoIndentAfterThis} +\begin{mytestenv} +Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, +vestibulum ut, placerat ac, adipiscing vitae, felis. +\end{mytestenv} + +Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer +id, vulputate a, magna. Donec vehicula augue eu neque. +\end{niashow} + + + + +\DescribeMacroExtended{\NoIndentAfterCmd}[\marg{command}] +By using \cs{NoIndentAfterCmd}, macros can be modified. There probably may not +be many situations where this is useful, but perhaps this one: + +\begin{niashow} +Lorem ipsum dolor sit amet, consectetuer adipiscing elit: + +\[ 1 + 1 = 2 \] + +Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur +dictum gravida mauris: + +\NoIndentAfterCmd{\]} + +\[ 2 + 2 = 4 \] + +Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec +vehicula augue eu neque. +\end{niashow} + + + +\DescribeMacroExtended{\NoIndentAfterThis} +Finally, this is the most primitive macro offered by the package. It forces a +paragraph break and suppresses indentation for whatever follows: + +\begin{niashow} +Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, +vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida +mauris. \NoIndentAfterThis Nam arcu libero, nonummy eget, consectetuer id, +vulputate a, magna. Donec vehicula augue eu neque. +\end{niashow} + + + +\section{Acknowledgements} +This package resulted from \url{http://tex.stackexchange.com/q/112404} and the +excellent responses to it by \textsc{cgnieder} and \textsc{lockstep}. Although +it initially based on the proposed solution by \textsc{cgnieder}---as it was +simpler and more generally applicable---the answer by \textsc{lockstep} is +definitely worth reading. + + + +\StopEventually{^^A + \cleardoublepage\PrintIndex^^A + \PrintChanges^^A + \PrintToDos^^A +} +% +% \iffalse +%</dtx> +%<*package&body> +% \fi +% +%^^A \cleardoublepage +%^^A \appendix +% \section{Implementation} +% The only required packages are \pkg{etoolbox} as well as \pkg{xpatch}. +% \begin{macrocode} +\RequirePackage{etoolbox} +\RequirePackage{xpatch} +% \end{macrocode} +% +% \begin{macro}{\nia@scan} +% This command implements the main principle behind this package. It checks +% whether it is followed by a paragraph. If so, the command \cs{par} is +% temporarily changed using \cs{everypar}, so that the following paragraph is +% not indented. Immediately afterwards, default paragraph behavior is restored +% with \cs{@restorepar} (from the \LaTeXe\ kernel). +% \begin{macrocode} +\newcommand*\nia@scan{% + \kernel@ifnextchar\par{% + \par% + \def\par{% + \everypar{\setbox\z@\lastbox\everypar{}}% + \@restorepar% + }% + }{}% +} +% \end{macrocode} +% \end{macro}^^A \nia@scan +% +% \begin{macro}{\nia@afterendenv} +% This command is used for hooking into the ending routine of an environment at +% the latest possible point after \cs{ignorespaces}. It is heavily inspired by +% David Carlisle\footnote{\url{https://tex.stackexchange.com/a/179034/38481}} +% and uses a delimited argument in order to apply \cs{nia@scan} last. +% +% It is invoked via hook \cs{AfterEndEnvironment} provided by \pkg{etoolbox} +% and leaves everything between its invocation and \cs{ignorespaces}|\fi| at +% the very end of \cs{end} unchanged---even additonal material given through +% the same hook---and finally executes \cs{nia@scan}. +% \begin{macrocode} +\newcommand*\nia@afterendenv{} +\def\nia@afterendenv#1\ignorespaces\fi{#1\ignorespaces\fi\nia@scan} +% \end{macrocode} +% \end{macro}^^A \nia@afterendenv +% +% \begin{macro}{\NoIndentAfterThis} +% \begin{macro}{\NoIndentAfterCmd} +% \begin{macro}{\NoIndentAfterEnv} +% These are finally the user-level commands to activate the funtionality of +% \pkg{noindetafter} for the given \marg{environment}/\marg{macro} as well as +% immediate execution. +% \begin{macrocode} +\newrobustcmd*\NoIndentAfterThis{\nia@scan\par} +\newcommand*\NoIndentAfterCmd[1]{% + \xapptocmd#1{\NoIndentAfterThis}{}{% + \PackageWarning{noindentafter}{% + Patching `\string#1' failed!\MessageBreak% + `\string\NoIndentAfterCmd{\string#1}' won't work% + }% + }% +} +\newcommand*\NoIndentAfterEnv[1]{\AfterEndEnvironment{#1}{\nia@afterendenv}} +% \end{macrocode} +% \end{macro}^^A \NoIndentAfterEnv +% \end{macro}^^A \NoIndentAfterCmd +% \end{macro}^^A \NoIndentAfterThis +% +% \iffalse +%</package&body> +% \fi +% +% \Finale +% +\endinput diff --git a/macros/latex/contrib/pdfmanagement-testphase/CHANGELOG.md b/macros/latex/contrib/pdfmanagement-testphase/CHANGELOG.md index 2f09d1fbf8..d114f50eed 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/CHANGELOG.md +++ b/macros/latex/contrib/pdfmanagement-testphase/CHANGELOG.md @@ -5,6 +5,24 @@ first release 0.95a, 2021-02-23 will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), this project uses date-based 'snapshot' version identifiers. +## [2021-05-14 +### Fixed + - xcolor patch for [ps] type used in pstricks + - value of citecolor wasn't expanded (errored with tcolorbox) + - \url, \href, \hrefurl, \hrefrun and \hrefpdf leaves now vmode + - handling of pdfauthor, pdftitle and pdfsubject in hyperxmp patch + +### Changes + - the module for formfield and checkboxes has been in part rewritten to + better fit to the new module for textfield. + Keys and documentation has been extended. + +### Added + - generic command hooks have been added to \url, \href, \hrefurl, + \hrefrun and \hrefpdf. Their use require a latex 2021-06-01. + - dictionaries widget/AA, widget/AP, widget/MK and widget/BS in l3pdfannot. + - a module for textfields + ## [2021-03-17] ### Fixed diff --git a/macros/latex/contrib/pdfmanagement-testphase/README.md b/macros/latex/contrib/pdfmanagement-testphase/README.md index 40ae909e00..49840245c6 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/README.md +++ b/macros/latex/contrib/pdfmanagement-testphase/README.md @@ -1,6 +1,6 @@ # LaTeX PDF management testphase bundle -Version: 0.95c, 2021-03-17 +Version: 0.95d, 2021-05-14 This package is used during a test phase to load the new PDF management code of LaTeX. diff --git a/macros/latex/contrib/pdfmanagement-testphase/color-ltx.sty b/macros/latex/contrib/pdfmanagement-testphase/color-ltx.sty index 15754414a1..d8a6c9c408 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/color-ltx.sty +++ b/macros/latex/contrib/pdfmanagement-testphase/color-ltx.sty @@ -22,7 +22,7 @@ %% This file has the LPPL maintenance status "maintained". %% \NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{color-ltx}[2021-03-17 v0.95c +\ProvidesPackage{color-ltx}[2021-05-14 v0.95d Standard LaTeX Color (patched for l3color, part of pdfmanagement-testphase, original version 2021/03/07 v1.2e) (DPC)] \edef\Gin@codes{% \catcode`\noexpand\^^A\the\catcode`\^^A\relax diff --git a/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx b/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx index 8c60439dd3..30266d866c 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx @@ -86,7 +86,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -325,7 +325,8 @@ % \subsection{Options} % All \cs{href} commands and \cs{url} have an option argument for keyval syntax. % It accepts the following keys. Not all keys make sense for all keys, but they don't -% error, they are silently ignored. +% error, they are silently ignored. The optional argument can currently not be used together +% with the \cs{urldef} command. % % \begin{tabular}{llp{6cm}} % key & applicable commands & note\\\hline @@ -634,7 +635,7 @@ % The key is ignored with this driver. Instead the wanted standard should be declared % in \cs{DeclareDocumentMetadata}: % \begin{verbatim} -% \DeclareDocumentMetadata{standard=A-2b} +% \DeclareDocumentMetadata{pdfstandard=A-2b} % \end{verbatim} % Currently |A-1b|, |A-2b|, |A-3b| can be set. % The support for various requirements is still incomplete, but the parts that @@ -921,7 +922,7 @@ %<@@=hyp> % \end{macrocode} % \begin{macrocode} -\ProvidesFile{hgeneric-testphase.def}[2021-03-17 v0.95c % +\ProvidesFile{hgeneric-testphase.def}[2021-05-14 v0.95d % generic Hyperref driver for the LaTeX PDF management testphase bundle] \RequirePackage{etoolbox} %why? @@ -1241,10 +1242,12 @@ ,href / format .code:n = { \cs_set_eq:NN \@@_href_url_format #1 } } - +\hook_new_pair:nn{cmd/href/before}{cmd/href/after} \DeclareRobustCommand*{\href}[1][]{% - \begingroup + \mode_leave_vertical: + \hook_use:n{cmd/href/before} + \group_begin: \keys_set:nn { hyp / href } {#1} \let\protect\@unexpandable@protect \bool_if:NTF \l_@@_href_url_encode_bool @@ -1257,12 +1260,27 @@ \@ifnextchar\bgroup\Hy@href{\hyper@normalise\href@}% } +\begingroup + \catcode`\$=6 % + \catcode`\#=12 % + \gdef\href@$1{\expandafter\href@split$1##\\}% + \gdef\href@split$1#$2#$3\\$4{% + \hyper@@@@link{$1}{$2}{$4}%<---@@-docstrip doubling! + \endgroup + \hook_use:n{cmd/href/after} + }% +\endgroup -\DeclareRobustCommand*{\hrefurl}[1][]{ - \group_begin: - \keys_set:nn { hyp / href } {#1} - \let\protect\@unexpandable@protect - \bool_if:NTF \l_@@_href_url_encode_bool +\hook_new_pair:nn{cmd/hrefurl/before}{cmd/hrefurl/after} + +\DeclareRobustCommand*{\hrefurl}[1][] + { + \mode_leave_vertical: + \hook_use:n{cmd/href/before} + \group_begin: + \keys_set:nn { hyp / href } {#1} + \let\protect\@unexpandable@protect + \bool_if:NTF \l_@@_href_url_encode_bool { \tl_set:Nn \l__hyp_text_enc_uri_print_tl {utf8/URI} } @@ -1275,12 +1293,15 @@ { \exp_args:Nno\hyper@linkurl{#2}{\l_@@_href_url_protocol_tl#1} \group_end: + \hook_use:n{cmd/href/after} } - +\hook_new_pair:nn{cmd/hrefpdf/before}{cmd/hrefpdf/after} \DeclareRobustCommand*{\hrefpdf}[1][] { - \begingroup + \mode_leave_vertical: + \hook_use:n{cmd/hrefpdf/before} + \group_begin: \keys_set:nn { hyp / href } {#1} \let\protect\@unexpandable@protect \hyper@normalise\@@_href_pdf_aux:nn @@ -1288,11 +1309,16 @@ \cs_new_protected:Npn \@@_href_pdf_aux:nn #1 #2 { - \exp_args:Nnno\hyper@linkfile{#2}{#1}{\l_@@_href_pdf_destination_tl}\endgroup + \exp_args:Nnno\hyper@linkfile{#2}{#1}{\l_@@_href_pdf_destination_tl} + \group_end: + \hook_use:n{cmd/hrefpdf/after} } +\hook_new_pair:nn{cmd/hrefrun/before}{cmd/hrefrun/after} \DeclareRobustCommand*{\hrefrun}[1][] { + \mode_leave_vertical: + \hook_use:n{cmd/hrefrun/before} \group_begin: \keys_set:nn { hyp / href } {#1} \let\protect\@unexpandable@protect @@ -1303,10 +1329,16 @@ { \exp_args:Nnno\hyper@linklaunch{#2}{#1}{\l_@@_href_run_parameter_tl} \group_end: + \hook_use:n{cmd/hrefrun/after} } + +\hook_new_pair:nn{cmd/url/before}{cmd/url/after} + \DeclareRobustCommand*{\url}[1][] { + \mode_leave_vertical: + \hook_use:n{cmd/url/before} \group_begin: \keys_set:nn {hyp / href } {#1} \let\protect \@unexpandable@protect @@ -1326,9 +1358,23 @@ \hyper@linkurl{\@@_href_url_format {#1}} {\l_@@_href_url_protocol_tl#1} \group_end: + \hook_use:n{cmd/url/after} } +% \end{macrocode} +% the \cs{urldef} command doesn't like the optional argument, so we overwrite +% locally the \cs{url} command here: +% \begin{macrocode} + +\def\urldef#1#2{\begingroup\def\url{\hyper@normalise\url@}\setbox\z@\hbox\bgroup + \def\Url@HyperHook##1\endgroup{\Url@def{#1}{#2}}% + % Because hyperref breaks \urldef and does not define its own (Grrrr!)... + \def\url@##1{\egroup\endgroup\DeclareRobustCommand#1{#2{##1}}}% + #2} +% \end{macrocode} +% make the new commands compatible with \cs{pdfstringdef}: +% \begin{macrocode} \NewExpandableDocumentCommand\@@_secondoftwowithopt:wnn {omm}{#3} \pdfstringdefDisableCommands{\let\hrefurl\@@_secondoftwowithopt:wnn} \pdfstringdefDisableCommands{\let\hrefpdf\@@_secondoftwowithopt:wnn} @@ -1356,9 +1402,9 @@ \color_set:nn {hyp/color/citeborder}{hyp/color/cite!60!white} \keys_define:nn { hyp / setup } { - ,citecolor .code:n = {\@@_color_set:nn {hyp/color/cite}{#1}} + ,citecolor .code:n = {\@@_color_set:ne {hyp/color/cite}{#1}} ,citebordercolor - .code:n = {\@@_color_set:nn {hyp/color/citeborder}{#1}} + .code:n = {\@@_color_set:ne {hyp/color/citeborder}{#1}} } \hook_gput_code:nnn { hyp/link/cite }{hyp/cite} { @@ -2277,17 +2323,16 @@ % \section{Link decorations} % \subsection{Functions to export and select colors} % We support two input syntax: color expressions and model with values. -% \begin{function}{\@@_color_export:nnN,\@@_colormodel_export:nnnN} +% \begin{function}{\@@_color_export:nnN} % \begin{syntax} -% \cs{@@_color_export:nnN} \Arg{color} \Arg{export format} \meta{tlvar}\\ -% \cs{@@_colormodel_export:nnnN} \Arg{color model}\Arg{value} \Arg{export format} \meta{tlvar} +% \cs{@@_color_export:nnN} \Arg{color} \Arg{export format} \meta{tlvar} % \end{syntax} % This exports a color as space separated numbers as needed in in |/C|. % \Arg{color} should have either the format |[model]{value}| or be a color expression. % For examples: |[rgb]{1,0,.5}| or |red!50!blue|. The export format is either % |space-sep-cmyk| or |space-sep-rgb|. % \end{function} -% \begin{macro}{\@@_color_export:nnN,\@@_colormodel_export:nnnN} +% \begin{macro}{\@@_color_export:nnN,\@@_color_export_aux:wnnN} % Color keys need to parse color expressions. Two input types are supported: % |color=[rgb]{1,0,.5}| and |color=red!50!blue|. The colors are exported % to PDF syntax (space separated numbers). @@ -2296,14 +2341,14 @@ { \tl_if_head_eq_charcode:nNTF {#1}[ %] { - \@@_colormodel_export:wnnN #1 {#2} #3 + \@@_color_export_aux:wnnN #1 {#2} #3 } { \color_export:nnN {#1} {#2} #3 } } -\cs_new_protected:Npn \@@_colormodel_export:wnnN [#1] #2 #3 #4 +\cs_new_protected:Npn \@@_color_export_aux:wnnN [#1] #2 #3 #4 { \color_export:nnnN {#1}{#2}{#3}#4 } @@ -2320,7 +2365,7 @@ % \Arg{color} should have either the format |[model]{value}| or be a color expression. % For examples: |[rgb]{1,0,.5}| or |red!50!blue| % \end{function} -% \begin{macro}{\@@_color_select:n,\@@_colormodel_select_aux:wn} +% \begin{macro}{\@@_color_select:n,\@@_color_select_aux:wn} % Color keys need to parse color expressions. Two input types are supported: % |color=[rgb]{1,0,.5}| and |color=red!50!blue|. % \begin{macrocode} @@ -2328,14 +2373,14 @@ { \tl_if_head_eq_charcode:nNTF {#1}[ %] { - \@@_colormodel_select_aux:wn #1 + \@@_color_select_aux:wn #1 } { \color_select:n {#1} } } -\cs_new_protected:Npn \@@_colormodel_select_aux:wn [#1] #2 +\cs_new_protected:Npn \@@_color_select_aux:wn [#1] #2 { \color_select:nn {#1}{#2} } @@ -2352,7 +2397,7 @@ % \Arg{color} should have either the format |[model]{value}| or be a color expression. % For examples: |[rgb]{1,0,.5}| or |red!50!blue| % \end{function} -% \begin{macro}{\@@_color_set:nn,\@@_colormodel_set_aux:nwn} +% \begin{macro}{\@@_color_set:nn,\@@_color_set_aux:nwn} % Color keys need to parse color expressions. Two input types are supported: % |color=[rgb]{1,0,.5}| and |color=red!50!blue|. % \begin{macrocode} @@ -2360,14 +2405,14 @@ { \tl_if_head_eq_charcode:nNTF {#2}[ %] { - \@@_colormodel_set_aux:nwn { #1 } #2 + \@@_color_set_aux:nwn { #1 } #2 } { \color_set:nn {#1} {#2} } } -\cs_new_protected:Npn \@@_colormodel_set_aux:nwn #1 [#2] #3 +\cs_new_protected:Npn \@@_color_set_aux:nwn #1 [#2] #3 { \color_set:nnn {#1}{#2}{#3} } @@ -2621,17 +2666,17 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_ocg_init: { - \pdf_object_new:nn { l_@@_ocg_view_dict_obj } { dict } - \pdf_object_new:nn { l_@@_ocg_print_dict_obj } { dict } - \pdf_object_new:nn { l_@@_ocg_config_dict_obj } { dict } - \pdf_object_new:nn { l_@@_ocg_ref_array_obj } { array } - \pdf_object_write:nx { l_@@_ocg_ref_array_obj } + \pdf_object_new:nn { @@/OCG/View } { dict } + \pdf_object_new:nn { @@/OCG/Print } { dict } + \pdf_object_new:nn { @@/OCG/config } { dict } + \pdf_object_new:nn { @@/OCG/refarray } { array } + \pdf_object_write:nx { @@/OCG/refarray } { - \pdf_object_ref:n { l_@@_ocg_view_dict_obj } + \pdf_object_ref:n { @@/OCG/View } \c_space_tl - \pdf_object_ref:n { l_@@_ocg_print_dict_obj } + \pdf_object_ref:n { @@/OCG/Print } } - \pdf_object_write:nn { l_@@_ocg_view_dict_obj } + \pdf_object_write:nn { @@/OCG/View } { /Type/OCG /Name(View) @@ -2641,7 +2686,7 @@ /View <</ViewState/ON >>~ >> } - \pdf_object_write:nn { l_@@_ocg_print_dict_obj } + \pdf_object_write:nn { @@/OCG/Print } { /Type/OCG /Name(Print) @@ -2651,30 +2696,30 @@ /View <</ViewState/OFF>>~ >> } - \pdfmanagement_add:nnx { Catalog / OCProperties }{OCGs }{ \pdf_object_ref:n {l_@@_ocg_view_dict_obj} } - \pdfmanagement_add:nnx { Catalog / OCProperties }{OCGs }{ \pdf_object_ref:n {l_@@_ocg_print_dict_obj} } - \pdf_object_write:nx { l_@@_ocg_config_dict_obj } + \pdfmanagement_add:nnx { Catalog / OCProperties }{OCGs }{ \pdf_object_ref:n {@@/OCG/View} } + \pdfmanagement_add:nnx { Catalog / OCProperties }{OCGs }{ \pdf_object_ref:n {@@/OCG/Print} } + \pdf_object_write:nx { @@/OCG/config } { - /OFF[\pdf_object_ref:n { l_@@_ocg_print_dict_obj }] + /OFF[\pdf_object_ref:n { @@/OCG/Print }] /AS[ << /Event/View - /OCGs\c_space_tl \pdf_object_ref:n { l_@@_ocg_ref_array_obj } + /OCGs\c_space_tl \pdf_object_ref:n { @@/OCG/refarray } /Category[/View] >> << /Event/Print - /OCGs\c_space_tl \pdf_object_ref:n { l_@@_ocg_ref_array_obj } + /OCGs\c_space_tl \pdf_object_ref:n { @@/OCG/refarray } /Category[/Print] >> << /Event/Export - /OCGs\c_space_tl \pdf_object_ref:n { l_@@_ocg_ref_array_obj } + /OCGs\c_space_tl \pdf_object_ref:n { @@/OCG/refarray } /Category[/Print] >> ] } - \pdfmanagement_add:nnx { Catalog / OCProperties }{ D }{ \pdf_object_ref:n { l_@@_ocg_config_dict_obj} } + \pdfmanagement_add:nnx { Catalog / OCProperties }{ D }{ \pdf_object_ref:n { @@/OCG/config} } \cs_gset:Npn \@@_ocg_init: {} } % \end{macrocode} @@ -2704,10 +2749,10 @@ \hbox_set_end: \mbox { - \pdf_bdcobject:nn {OC}{l_@@_ocg_print_dict_obj} + \pdf_bdcobject:nn {OC}{@@/OCG/Print} \hbox_overlap_right:n { \box_use:N \l_@@_tmpa_box } \pdf_emc: - \pdf_bdcobject:nn {OC}{l_@@_ocg_view_dict_obj} + \pdf_bdcobject:nn {OC}{@@/OCG/View} \group_begin: \color_select:n { hyp/color/#1 } \box_use_drop:N \l_@@_tmpa_box @@ -4187,9 +4232,9 @@ } } \pdfmanagement_add:nnx {Catalog / AcroForm/DR/Font } - {ZaDb} {\pdf_object_ref:n {l_@@_font_zapfdingbats_obj} } + {ZaDb} {\pdf_object_ref:n {@@/Font/ZaDb} } \pdfmanagement_add:nnx {Catalog / AcroForm/DR/Font } - {Helv} {\pdf_object_ref:n {l_@@_font_helvetica_obj} } + {Helv} {\pdf_object_ref:n {@@/Font/Helv} } \pdfmanagement_add:nnx {Catalog /AcroForm} {DA}{(/Helv~10~Tf~0~g)} \pdfmeta_standard_verify:nTF {form_no_NeedAppearance} @@ -4601,10 +4646,10 @@ \ExplSyntaxOn \def\Hy@FormObjects { - \pdf_object_new:nn {l_@@_encoding_pdfdoc_obj } { dict } - \pdf_object_new:nn {l_@@_font_zapfdingbats_obj } { dict } - \pdf_object_new:nn {l_@@_font_helvetica_obj } { dict } - \pdf_object_write:nx {l_@@_encoding_pdfdoc_obj } + \pdf_object_new:nn {@@/Encoding/pdfdoc } { dict } + \pdf_object_new:nn {@@/Font/ZaDb } { dict } + \pdf_object_new:nn {@@/Font/Helv } { dict } + \pdf_object_write:nx {@@/Encoding/pdfdoc } { /Type/Encoding /Differences[ @@ -4646,20 +4691,20 @@ /uacute/ucircumflex/udieresis/yacute/thorn/ydieresis ] } - \pdf_object_write:nn {l_@@_font_zapfdingbats_obj } + \pdf_object_write:nn {@@/Font/ZaDb } { /Type/Font /Subtype/Type1 /Name/ZaDb /BaseFont/ZapfDingbats } - \pdf_object_write:nx {l_@@_font_helvetica_obj } + \pdf_object_write:nx {@@/Font/Helv } { /Type/Font /Subtype/Type1 /Name/Helv /BaseFont/Helvetica - /Encoding~\pdf_object_ref:n { l_@@_encoding_pdfdoc_obj } + /Encoding~\pdf_object_ref:n { @@/Encoding/pdfdoc } } \global\let\Hy@FormObjects\relax } diff --git a/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.pdf b/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.pdf Binary files differindex ddb0c9b2b9..fb13e4b8e6 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/hyperxmp-patches-tmp-ltx.sty b/macros/latex/contrib/pdfmanagement-testphase/hyperxmp-patches-tmp-ltx.sty index b38a47f09c..ab8723947e 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/hyperxmp-patches-tmp-ltx.sty +++ b/macros/latex/contrib/pdfmanagement-testphase/hyperxmp-patches-tmp-ltx.sty @@ -19,7 +19,7 @@ % % for those people who are interested. \NeedsTeXFormat{LaTeX2e}[2020/10/01] -\ProvidesExplPackage{hyperxmp-patches-tmp-ltx}{2021-03-17}{0.95c} +\ProvidesExplPackage{hyperxmp-patches-tmp-ltx}{2021-05-14}{0.95d} {Store hyperref metadata in XMP format / temporay patches to test pdfresource management ... UF} \cs_if_exist:NT \pdfmanagement_add:nnn @@ -103,8 +103,8 @@ ,pdfcontacturl ,pdfdate %hyperref, needs probably special handling - ,pdftitle - ,pdfsubject + % ,pdftitle %see below + % ,pdfsubject %see below ,pdfkeywords ,pdfproducer } @@ -115,9 +115,15 @@ % pdfauthor, this is only a work around for simple author % TODO needs improvement + \exp_args:NNe \pdfstringdef\@pdfauthor{\GetDocumentProperties{hyperref/pdfauthor}} \cs_set_eq:NN\hyxmp@pdfauthor\@pdfauthor - + \exp_args:NNe + \pdfstringdef\@pdfsubject{\GetDocumentProperties{hyperref/pdfsubject}} + \cs_set_eq:NN\hyxmp@pdfsubject\@pdfsubject + \exp_args:NNe + \pdfstringdef\@pdftitle{\GetDocumentProperties{hyperref/pdftitle}} + \cs_set_eq:NN\hyxmp@pdftitle\@pdftitle % pdflang, \tl_if_exist:cF{@pdflang}{\tl_new:c{@pdflang}} \tl_set:cx {@pdflang}{\GetDocumentProperties{document/lang}} diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3backend-testphase.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3backend-testphase.dtx index 1b1e1b1b91..497491f3b7 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3backend-testphase.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3backend-testphase.dtx @@ -45,7 +45,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % @@ -56,27 +56,27 @@ % \begin{macrocode} %<drivers>\ProvidesExplFile %<*dvipdfmx> - {l3backend-testphase-dvipdfmx.def}{2021-03-17}{} + {l3backend-testphase-dvipdfmx.def}{2021-05-14}{} {LaTeX~PDF~management~testphase~bundle~backend~support: dvipdfmx} %</dvipdfmx> %<*dvips> - {l3backend-testphase-dvips.def}{2021-03-17}{} + {l3backend-testphase-dvips.def}{2021-05-14}{} {LaTeX~PDF~management~testphase~bundle~backend~support: dvips} %</dvips> %<*dvisvgm> - {l3backend-testphase-dvisvgm.def}{2021-03-17}{} + {l3backend-testphase-dvisvgm.def}{2021-05-14}{} {LaTeX~PDF~management~testphase~bundle~backend~support: dvisvgm} %</dvisvgm> %<*luatex> - {l3backend-testphase-luatex.def}{2021-03-17}{} + {l3backend-testphase-luatex.def}{2021-05-14}{} {LaTeX~PDF~management~testphase~bundle~backend~support: PDF output (LuaTeX)} %</luatex> %<*pdftex> - {l3backend-testphase-pdftex.def}{2021-03-17}{} + {l3backend-testphase-pdftex.def}{2021-05-14}{} {LaTeX~PDF~management~testphase~bundle~backend~support: PDF output (pdfTeX)} %</pdftex> %<*xdvipdfmx> - {l3backend-testphase-xetex.def}{2021-03-17}{} + {l3backend-testphase-xetex.def}{2021-05-14}{} {LaTeX~PDF~management~testphase~bundle~backend~support: XeTeX} %</xdvipdfmx> % \end{macrocode} @@ -590,14 +590,14 @@ %create the backend objects: \clist_map_inline:Nn \c_@@_backend_PageResources_clist { - \@@_backend_object_new:nn {Page/Resources/#1} {dict} + \@@_backend_object_new:nn {@@/Page/Resources/#1} {dict} \cs_if_exist:NT \tex_directlua:D { \tex_directlua:D { - ltx.@@.object["Page/Resources/#1"] + ltx.@@.object["@@/Page/Resources/#1"] = - "\@@_backend_object_ref:n{Page/Resources/#1}" + "\@@_backend_object_ref:n{@@/Page/Resources/#1}" } } } @@ -631,7 +631,7 @@ { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/##1} } { \@@_backend_object_write:nx - { Page/Resources/##1 } + { @@/Page/Resources/##1 } { \pdfdict_use:n { g_@@_Core/Page/Resources/##1} } } } @@ -651,8 +651,8 @@ % \clist_map_inline:Nn \c_@@_backend_PageResources_clist { - \@@_backend_object_new:nn { Page/Resources/#1 } { dict } - \hook_gput_code:nnn{shipout/firstpage}{pdf}{\@@_backend_object_write:nn { Page/Resources/#1 } {}} + \@@_backend_object_new:nn { @@/Page/Resources/#1 } { dict } + \hook_gput_code:nnn{shipout/firstpage}{pdf}{\@@_backend_object_write:nn { @@/Page/Resources/#1 } {}} } \cs_new_protected:Npn \@@_backend_PageResources:n #1 { @@ -667,7 +667,7 @@ %objects are not filled with \pdf_object_write as this is not additive! \@@_backend:x { - put~\@@_backend_object_ref:n {Page/Resources/#1}<</#2~#3>> + put~\@@_backend_object_ref:n {@@/Page/Resources/#1}<</#2~#3>> } } @@ -847,7 +847,7 @@ \__kernel_backend_literal:x { pdf:put~@resources~ - <</##1~\@@_backend_object_ref:n {Page/Resources/##1}>> + <</##1~\@@_backend_object_ref:n {@@/Page/Resources/##1}>> } } } @@ -1042,7 +1042,7 @@ \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/#1} } { - \pdfdict_item:ne { #1 }{ \pdf_object_ref:n {Page/Resources/#1}} + \pdfdict_item:ne { #1 }{ \pdf_object_ref:n {@@/Page/Resources/#1}} } } @@ -1243,22 +1243,22 @@ \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/ExtGState } } { - /ExtGState~ \pdf_object_ref:n { Page/Resources/ExtGState } + /ExtGState~ \pdf_object_ref:n { @@/Page/Resources/ExtGState } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/Pattern } } { - /Pattern~ \pdf_object_ref:n { Page/Resources/Pattern } + /Pattern~ \pdf_object_ref:n { @@/Page/Resources/Pattern } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/Shading } } { - /Shading~ \pdf_object_ref:n { Page/Resources/Shading } + /Shading~ \pdf_object_ref:n { @@/Page/Resources/Shading } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/ColorSpace } } { - /ColorSpace~ \pdf_object_ref:n { Page/Resources/ColorSpace } + /ColorSpace~ \pdf_object_ref:n { @@/Page/Resources/ColorSpace } } } \l_@@_backend_tmpa_box @@ -1323,22 +1323,22 @@ \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/ExtGState } } { - /ExtGState~ \pdf_object_ref:n { Page/Resources/ExtGState } + /ExtGState~ \pdf_object_ref:n { @@/Page/Resources/ExtGState } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/Pattern } } { - /Pattern~ \pdf_object_ref:n { Page/Resources/Pattern } + /Pattern~ \pdf_object_ref:n { @@/Page/Resources/Pattern } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/Shading } } { - /Shading~ \pdf_object_ref:n { Page/Resources/Shading } + /Shading~ \pdf_object_ref:n { @@/Page/Resources/Shading } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g_@@_Core/Page/Resources/ColorSpace } } { - /ColorSpace~ \pdf_object_ref:n { Page/Resources/ColorSpace } + /ColorSpace~ \pdf_object_ref:n { @@/Page/Resources/ColorSpace } } } \l_@@_backend_tmpa_box @@ -1414,21 +1414,21 @@ { put~ @resources ~ << - /ExtGState~ \pdf_object_ref:n { Page/Resources/ExtGState } + /ExtGState~ \pdf_object_ref:n { @@/Page/Resources/ExtGState } >> } \@@_backend:x { put~ @resources ~ << - /Pattern~ \pdf_object_ref:n { Page/Resources/Pattern } + /Pattern~ \pdf_object_ref:n { @@/Page/Resources/Pattern } >> } \@@_backend:x { put~ @resources ~ << - /Shading~ \pdf_object_ref:n { Page/Resources/Shading } + /Shading~ \pdf_object_ref:n { @@/Page/Resources/Shading } >> } \@@_backend:x @@ -1436,7 +1436,7 @@ put~ @resources ~ << /ColorSpace~ - \pdf_object_ref:n { Page/Resources/ColorSpace } + \pdf_object_ref:n { @@/Page/Resources/ColorSpace } >> } \exp_args:Nx @@ -1582,7 +1582,7 @@ local function @@_backend_PageResources_gpush (page) end for i,name in ipairs(ResourceList) do if ltx.@@.Page.Resources[name] then - token = token .. "/"..name.." "..ltx.pdf.object_ref("Page/Resources/"..name) + token = token .. "/"..name.." "..ltx.pdf.object_ref("@@/Page/Resources/"..name) end end return token diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3backend-testphase.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3backend-testphase.pdf Binary files differindex 6e5e8afd77..6e8a0d0155 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3backend-testphase.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3backend-testphase.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfannot.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdfannot.dtx index 256e3e6dc9..c8eddc0806 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfannot.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfannot.dtx @@ -52,7 +52,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -354,9 +354,9 @@ % /F flag in an annotation. % It can be used for example like this: % \begin{verbatim} -% \pdfannot_dict_put:nnn {link/URI} {F} -% { \bitset_to_arabic:N \l_pdfannot_F_bitset } % \bitset_set_true:Nn \l_pdfannot_F_bitset {Print} +% \pdfannot_dict_put:nnx {link/URI} {F} +% { \bitset_to_arabic:N \l_pdfannot_F_bitset } % \end{verbatim} % The known keys for the bitset are |Invisible|, |Hidden|, % |Print|, |NoZoom|, |NoRotate|, |NoView|, |ReadOnly|, |Locked|, |ToggleNoView|, @@ -382,6 +382,11 @@ % is prefilled with \texttt{/Subtype/Widget}). % The hooks \texttt{pdfannot/widget/before} and \texttt{pdfannot/widget/after} % are executed before and after the widget. +% The widget has four subdirectories, |widget/AA|, |widget/AP|, |widget/MK| and +% |widget/BS| +% which can be filled with \cs{pdfannot_dict_put:nnn} and will be used if not +% empty. +% % \end{function} % \end{documentation} % @@ -392,7 +397,7 @@ % \begin{macrocode} %<@@=pdfannot> %<*header> -\ProvidesExplPackage{l3pdfannot}{2021-03-17}{0.95c} +\ProvidesExplPackage{l3pdfannot}{2021-05-14}{0.95d} {PDF-annotations} \RequirePackage{l3pdfdict} %</header> @@ -463,21 +468,56 @@ % the subtype setting (the /Type is added by the backend). % \begin{macrocode} \pdfdict_new:n { l_@@/widget } + \pdfdict_new:n { l_@@/widget/AA } + \pdfdict_new:n { l_@@/widget/AP } + \pdfdict_new:n { l_@@/widget/MK } + \pdfdict_new:n { l_@@/widget/BS } \pdfdict_put:nnn { l_@@/widget }{ Subtype }{ /Widget } \hook_new_pair:nn {pdfannot/widget/before} {pdfannot/widget/after} - \hook_new_pair:nn - {pdfannot/widget/begin} - {pdfannot/widget/end} \cs_new_protected:Npn \pdfannot_widget_box:nnn #1 #2 #3 { \hook_use:n { pdfannot/widget/before } + \group_begin: + \pdfmeta_standard_verify:nT + {annot_widget_no_AA} + { + \pdfdict_if_empty:nF { l_@@/widget/AA } + { + \pdf_object_unnamed_write:nx {dict}{\pdfdict_use:n{l_@@/widget/AA}} + \pdfdict_put:nnx { l_@@/widget } + {AA} + {\pdf_object_ref_last:} + } + } + \pdfdict_if_empty:nF { l_@@/widget/AP } + { + \pdf_object_unnamed_write:nx {dict}{\pdfdict_use:n{l_@@/widget/AP}} + \pdfdict_put:nnx { l_@@/widget } + {AP} + {\pdf_object_ref_last:} + } + \pdfdict_if_empty:nF { l_@@/widget/MK } + { + \pdf_object_unnamed_write:nx {dict}{\pdfdict_use:n{l_@@/widget/MK}} + \pdfdict_put:nnx { l_@@/widget } + {MK} + {\pdf_object_ref_last:} + } + \pdfdict_if_empty:nF { l_@@/widget/BS } + { + \pdf_object_unnamed_write:nx {dict}{\pdfdict_use:n{l_@@/widget/BS}} + \pdfdict_put:nnx { l_@@/widget } + {BS} + {\pdf_object_ref_last:} + } \pdfannot_box:nnnx {#1}{#2}{#3} { \pdfdict_use:n { l_@@/widget} } - \hook_use:n { pdfannot/widget/after } + \hook_use:n { pdfannot/widget/end } + \group_end: \bool_gset_false:N\g_@@_use_lastlink_bool } % \end{macrocode} diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfannot.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdfannot.pdf Binary files differindex 3e647106b5..8025552014 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfannot.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfannot.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfdict.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdfdict.dtx index 25a3599445..b23ff4508f 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfdict.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfdict.dtx @@ -53,7 +53,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -212,7 +212,7 @@ % \begin{macrocode} %<@@=pdfdict> %<*header> -\ProvidesExplPackage{l3pdfdict}{2021-03-17}{0.95c} +\ProvidesExplPackage{l3pdfdict}{2021-05-14}{0.95d} {Tools for PDF dictionaries (LaTeX PDF management testphase bundle)} %</header> % \end{macrocode} diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfdict.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdfdict.pdf Binary files differindex 970086e088..bb3eb95d68 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfdict.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfdict.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx new file mode 100644 index 0000000000..681a8d7059 --- /dev/null +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx @@ -0,0 +1,433 @@ +% \iffalse meta-comment +% +%% File: l3pdfpdffield-checkbox.dtx +% +% Copyright (C) 2021 The LaTeX Project +% +% It may be distributed and/or modified under the conditions of the +% LaTeX Project Public License (LPPL), either version 1.3c of this +% license or (at your option) any later version. The latest version +% of this license is in the file +% +% http://www.latex-project.org/lppl.txt +% +% This file is part of the "LaTeX PDF management testphase bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/pdfresources +% +% for those people who are interested. +% +%<*driver> +\RequirePackage{pdfmanagement-testphase} +\DeclareDocumentMetadata{} +\makeatletter +\declare@file@substitution{doc.sty}{doc-v3beta.sty} +\makeatother +\documentclass[full]{l3doc} +\usepackage{array,booktabs} +\usepackage{l3pdffield-testphase,bearwear} +\hypersetup{pdfauthor=The LaTeX Project, + pdftitle=l3pdffield (LaTeX PDF management testphase bundle)} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% \NewDocElement[ +% idxgroup=checkbox keys, +% idxtype = {checkbox key}, +% printtype= \textit{checkbox key} +% ]{Checkboxkey}{checkboxkey} +% \providecommand\hook[1]{\texttt{#1}} +% \ExplSyntaxOn +% \pdffield_appearance:nn {pdffield/bear/Yes} +% { +% \tikz\bear\bearwear[shirt=red,body~deco={\node[font=\tiny\bfseries,white]~at~(beartummy){Yes};}]; +% } +% \pdffield_appearance:nn {pdffield/bear/Off} +% { +% \tikz\bear\bearwear[body~deco={\node[font=\tiny\bfseries,white]~at~(beartummy){Off};}]; +% } +% \ExplSyntaxOff +% \title{^^A +% The \pkg{l3pdffield-checkbox} module\\ Commands to create checkbox form fields ^^A +% \\ \LaTeX{} PDF management testphase bundle +% } +% +% \author{^^A +% The \LaTeX{} Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Version 0.95d, released 2021-05-14} +% +% \maketitle +% \begin{documentation} +% \section{\pkg{l3pdffield-checkbox} Introduction} +% This is the documentation for checkbox fields, for general information about form fields +% check the documentation l3pdffield. +% +% +% +% Please keep in mind +% \begin{itemize} +% \item Not every PDF viewer supports checkboxes. +% \item The handling can depend on settings in the PDF viewer. In adobe reader for +% example I had to disable an option to avoid that it tries to create an appearance +% itself +% \item Standards like pdf/A disable features of form fields too +% (as you typically can't change the PDF). +% \end{itemize} +% \section{Checkboxes} +% Click me: +% \ExplSyntaxOn +% \pdffield_checkbox:n{name=bear,appearance=pdffield/bear,width=23pt,height=30pt,depth=10pt} +% \ExplSyntaxOff +% +% \bigskip +% \subsection{Commands} +% \begin{function}{\pdffield_checkbox:n} +% \begin{syntax} +% \cs{pdffield_checkbox:n}\Arg{key val list} +% \end{syntax} +% This creates a checkbox to check and uncheck. The list of allowed keys is described below. +% The \meta{key val list} should at least set the name, without it the default name +% |checkbox| is used. Checkboxes with the same +% name belong to the same field and are checked and unchecked together. The default appearance +% is a quadratic frame with a \cs{texttimes} in it for the checked case. +% The default appearance is setup at the first use and will use the font family +% active at that time. +% \end{function} +% +% +% \subsection{Keys} +% +% The new checkbox command accept all field and annot keys from l3pdffield. +% A few keys are disabled or are forced to specific values. +% The |appearance| keys have a more checkbox specific +% behaviour, other keys have other defaults than with the basic commands. +% Additionally there +% are a small number of keys specific to a checkbox. +% +% +% Disabled keys are +% \begin{itemize} +% \item |V|, |DV|, |AS|: use |checked| instead. +% \item |FT| is overwritten. +% \item For checkboxes only the field flags |ReadOnly|, |Required| and |NoExport| make sense. +% |Radio|, |Pushbotton| are set automatically automatically by the code +% as this is required for a checkbox. +% \end{itemize} +% +% \begin{function}{preset-checkbox} +% \begin{syntax} +% |preset-checkbox| = \Arg{key-val-list} +% \end{syntax} +% This allows to set default keys for a checkbox. +% \end{function} +% +% \begin{function}{name,T} +% \begin{syntax} +% |name| = \meta{partial name}\\ +% |T| = \meta{partial name} +% \end{syntax} +% This sets like the |T| key for fields the partial name of the field. The value +% shouldn't contain a period, be not empty and sensibly consist of simple chars. +% Additionally the value is used to create the field ID. +% This means that checkboxes with the same partial name are annotations +% with the same field as parent and are checked and unchecked together---this +% what is typically expected. +% The field ID is then internal and can not be used to +% attach another annotation. +% For explicit control of the field ID use the |fieldID| key. +% \end{function} +% +% \begin{function}{fieldID} +% \begin{syntax} +% |fieldID| = \meta{field ID}\\ +% \end{syntax} +% \emph{For experts only!} +% This allows to give the checkbox field a specific ID. This is only useful +% in the context of a larger fieldset or if you want to attach another annotation +% to the field with \cs{pdffield_annot:n}. If used wrongly you can +% easily create invalid fieldset. It allows you to create to fields with the +% same partial name, but if you want to see both +% you need to ensure that their full names are +% different---for example by adding some parent fields. +% \end{function} +% +% \begin{function}{parent} +% \begin{syntax} +% |parent| = \meta{field ID}\\ +% \end{syntax} +% This is only needed if the field should be part +% of a larger fieldset. The value should be a field ID of a field created previously +% with \cs{pdffield_field:nn}. +% \end{function} +% +% \begin{function}{altname,TU} +% \begin{syntax} +% |altname| = \meta{string}\\ +% |TU| = \meta{string}\\ +% \end{syntax} +% This is sets an alternative name for user interaction. +% This name can only be set at the first checkbox instance, when the field is initialized. +% \end{function} +% +% \begin{function}{mappingname,TM} +% \begin{syntax} +% |mappingname| = \meta{string}\\ +% |TM| = \meta{string}\\ +% \end{syntax} +% This is sets an alternative name for export. +% This name can only be set at the first checkbox instance, when the field is initialized. +% \end{function} +% +% \begin{function}{width,height,depth} +% \begin{syntax} +% |width| = \meta{dim expression}\\ +% |height| = \meta{dim expression}\\ +% |depth| = \meta{dim expression} +% \end{syntax} +% These keys allow to set the dimensions of checkbox instance. +% The value should be a dimension expression. By default +% |width| and |height| use \cs{normalbaselineskip}, the |depth| is zero. +% \end{function} +% +% \begin{function}{AP/N,appearance,AP/R,rollover-appearance,AP/D,down-appearance} +% \begin{syntax} +% |AP/N| = \meta{partial appearance name}\\ +% |appearance| = \meta{partial appearance name}\\ +% |AP/R| = \meta{partial appearance name}\\ +% |rollover-appearance| = \meta{partial appearance name}\\ +% |AP/D| = \meta{partial appearance name}\\ +% |down-appearance| = \meta{partial appearance name} +% \end{syntax} +% This keys sets the normal appearance, the rollover appearance (when the +% mouse hovers over the checkbox) and the down appearance (when the +% mouse clicks). They take as value a +% \meta{partial appearance name} and expects that \emph{two} form Xobjects +% \meta{partial appearance name}|/Yes| and \meta{partial appearance name}|/Off| +% has been created. The initial value is |pdffield/checkbox/default| +% for the normal appearance and shows a \cs{texttimes}. +% The other appearance are not set by default. +% \end{function} +% \begin{function}{checked} +% \begin{syntax} +% |checked| = |true|\verb"|"|false| +% \end{syntax} +% This is a boolean key which allows to set if the +% checkbox should be initially checked or not. It sets the |/V| and |/DV| key of the field +% and the |/AS| key of the annotation instance. It is possible to use different +% values for different instances, if one wants to confuse the user. +% \end{function} +% +% +% \subsection{Using with hyperref} +% The \cs{CheckBox} command from hyperref also prints a label, something that the +% command here doesn't do. A redefinition like the following should allow \cs{CheckBox} +% to use the commands of this module. Be aware that the behaviour will not be identical! +% Not every setting and key from \pkg{hyperref} has been copied. +% +% \begin{verbatim} +% \ExplSyntaxOn\makeatletter +% \def\@CheckBox[#1]#2{\LayoutCheckField{#2}{\pdffield_checkbox:n {name=#2,#1}}} +% \ExplSyntaxOff\makeatother +% \end{verbatim} +% +% \subsection{Some background} +% For some general background about fieldsets, fields and field annotations, please +% check \pkg{l3pdffield}. Here are only some remarks about the special case of +% checkboxes. +% +% A checkbox consist of a field along with one or more field annotations. +% The annotations can appear on more than one page or locations and if one instance +% is checked all other instances follows and are checked too. +% +% A checkbox has two different looks: checked and unchecked. The hyperref +% implementation uses symbolic names for the two states and adds some +% values with the /MK key and lets the PDF viewer +% create a look from them. But this doesn't work reliably and is one of the reasons +% why a reimplementation is needed. Also newer PDF versions +% deprecate the /NeedAppearances setting and require that such a look, +% an \enquote{appearance}, is given as form XObjects. +% So the code forces the use of two appearances. +% +% \end{documentation} +% +% \begin{implementation} +% \section{\pkg{l3pdffield-checkbox} Implementation} +% \begin{macrocode} +%<*package> +%<@@=pdffield> +% \end{macrocode} +% \subsection{Variables} +% \begin{macrocode} +% \end{macrocode} +% \subsection{Messages} +% \begin{macrocode} +% \end{macrocode} +% \subsection{Appearances} +% The default appearances are a cross (\cs{texttimes}), +% Every appearance should have two versions and follow the naming +% module/\meta{name}/Yes and module/\meta{name}/Off. +% \begin{macro}{@@/checkbox/default_appearances:} +% This defines the standard appearance. It is setup at the first +% use of a checkbox, and will adapt to the font family in use then. +% \begin{macrocode} +\cs_new_protected:cn {@@/checkbox/default_appearances:} + { + \pdffield_appearance:nn {pdffield/checkbox/default/Yes} + { + \normalsize + \fboxsep 0pt + \framebox + [ \dim_eval:n { \box_ht:N\strutbox+\box_dp:N\strutbox } ] + { \texttimes \strut } + } + \pdffield_appearance:nn {pdffield/checkbox/default/Off} + { + \normalsize + \fboxsep 0pt + \framebox + [ \dim_eval:n { \box_ht:N\strutbox+\box_dp:N\strutbox } ] + { \phantom{\texttimes} \strut } + } + \cs_gset_eq:cN {@@/checkbox/default_appearances:} \prg_do_nothing: + } +% \end{macrocode} +% \end{macro} +% +%\subsection{Creating the field} +% A field should be created if the name doesn't exist +% \begin{macrocode} +\cs_new_protected:Npn \@@_checkbox_field:n #1 %name + { + \pdf_object_if_exist:nF {@@/field/@@/checkbox/#1} + { + \@@_field:n { @@/checkbox/#1 } + } + \keys_set:nn {pdffield}{parent=@@/checkbox/#1} + } +\cs_generate_variant:Nn \@@_checkbox_field:n {V} +% \end{macrocode} +% \subsection{Assembling the checkbox} + +% \begin{macro}{\@@_checkbox:n} +% \begin{macrocode} +\cs_new_protected:Npn \@@_checkbox:n #1 + { + \group_begin: + \use:c {@@/checkbox/default_appearances:} + \cs_set_eq:NN\@@_appearance_handler:nnn \@@_checkbox_appearance_handler:nnn +% \end{macrocode} +% Setting up the defaults. +% \begin{macrocode} + \keys_set:nn {pdffield} + { + fieldID=, + name=checkbox, + appearance = pdffield/checkbox/default, + checked=false, + width = \normalbaselineskip, + height = \normalbaselineskip, + } +% \end{macrocode} +% Value keys should be undefined. +% \begin{macrocode} + \@@_key_disable:nnn{checkbox}{V}{checked} + \@@_key_disable:nnn{checkbox}{DV}{checked} + \@@_key_disable:nnn{checkbox}{AS}{checked} + \keys_set:nn { pdffield }{@@/preset/checkbox,#1} + \keys_set:nn { pdffield } + { + ,unsetFf={Radio,Pushbutton} + ,FT= Btn + } + \tl_if_empty:NT\l_@@_fieldID_tl + { + \pdfdict_get:nnN {l_@@/field}{T}\l_@@_fieldID_tl + \tl_put_left:Nn \l_@@_fieldID_tl {@@/checkbox/} + } + \@@_checkbox_field:V\l_@@_fieldID_tl + \@@_annot: + \group_end: + } +% \end{macrocode} +% \end{macro} +% +% \subsection{Keys} +% Most keys are inherited simply the ones from the generic field and annot keys. +% A key to decide if the box is initially checked or not. +% We stay in the same family so that we can build a style. +% \begin{macrocode} +\keys_define:nn { pdffield } + { + ,checked .choice: + ,checked / false .code:n = + { + \pdfdict_put:nnx { l_@@/field }{V} { /Off } + \pdfdict_put:nnx { l_@@/field }{DV}{ /Off } + \pdfannot_dict_put:nnn {widget}{AS}{ /Off } + } + ,checked / true .code:n = + { + \pdfdict_put:nnx { l_@@/field }{V} { /Yes } + \pdfdict_put:nnx { l_@@/field }{DV}{ /Yes } + \pdfannot_dict_put:nnn {widget}{AS}{ /Yes } + } + ,checked .default:n = {true} + ,checked .groups:n = {checkbox} + } +% \end{macrocode} +% And a key to set a dedicated field ID +% \begin{macrocode} +\keys_define:nn { pdffield } + { + fieldID .tl_set:N = \l_@@_fieldID_tl + } +% \end{macrocode} +% \begin{macro}{\@@_checkbox_appearance_handler:nnn} +% \begin{macrocode} +\cs_new_protected:Npn \@@_checkbox_appearance_handler:nnn #1 #2 #3 %name, type, text + { + \pdfxform_if_exist:nTF { #1/Yes } + { + \pdf_object_if_exist:nF {@@/checkbox/AP/#1} + { + \pdf_object_new:nn {@@/checkbox/AP/#1}{dict} + \pdf_object_write:nx + {@@/checkbox/AP/#1} + { + /Yes ~ \pdfxform_ref:n { #1/Yes} + /Off ~ \pdfxform_ref:n { #1/Off} + } + } + \pdfannot_dict_put:nnx {widget/AP}{#2}{\pdf_object_ref:n{@@/checkbox/AP/#1}} + } + { + \msg_error:nnnn{pdffield}{appearance-missing}{#1}{#3} + } + } + +% \end{macrocode} +% +% \end{macro} +% +% \subsection{user commands} +% \begin{macro}{\pdffield_checkbox:n} +% \begin{macrocode} +\cs_set_eq:NN \pdffield_checkbox:n \@@_checkbox:n +%</package> +% \end{macrocode} +% \end{macro} +%\end{implementation} diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.pdf Binary files differnew file mode 100644 index 0000000000..e4b957a528 --- /dev/null +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-radiobutton.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-radiobutton.pdf Binary files differnew file mode 100644 index 0000000000..5328b6e77e --- /dev/null +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-radiobutton.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx new file mode 100644 index 0000000000..a8ea21042f --- /dev/null +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx @@ -0,0 +1,508 @@ +% \iffalse meta-comment +% +%% File: l3pdfpdffield-textfield.dtx +% +% Copyright (C) 2021 The LaTeX Project +% +% It may be distributed and/or modified under the conditions of the +% LaTeX Project Public License (LPPL), either version 1.3c of this +% license or (at your option) any later version. The latest version +% of this license is in the file +% +% http://www.latex-project.org/lppl.txt +% +% This file is part of the "LaTeX PDF management testphase bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/pdfresources +% +% for those people who are interested. +% +%<*driver> +\RequirePackage{pdfmanagement-testphase} +\DeclareDocumentMetadata{} +\makeatletter +\declare@file@substitution{doc.sty}{doc-v3beta.sty} +\makeatother +\documentclass[full]{l3doc} +\usepackage{array,booktabs} +\usepackage{l3pdffield-testphase} +\hypersetup{pdfauthor=The LaTeX Project, + pdftitle=l3pdffield (LaTeX PDF management testphase bundle)} +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% \providecommand\hook[1]{\texttt{#1}} +% \title{^^A +% The \pkg{l3pdffield-textfield} module\\ Commands to create textfield form fields ^^A +% \\ \LaTeX{} PDF management testphase bundle +% } +% +% \author{^^A +% The \LaTeX{} Project\thanks +% {^^A +% E-mail: +% \href{mailto:latex-team@latex-project.org} +% {latex-team@latex-project.org}^^A +% }^^A +% } +% +% \date{Version 0.95c, released 2021-03-17} +% +% \maketitle +% \begin{documentation} +% \section{\pkg{l3pdffield-textfield} Introduction} +% \ExplSyntaxOn +% Enter~your~name:\quad \pdffield_textfield:n{name=name,fontcolor=[RGB]{00,33,99},width=5cm} +% \ExplSyntaxOff +% +% This is the documentation for textfield fields, for general information about form fields +% check the documentation l3pdffield. +% +% Textfields allows the user to input text which is then rendered by the PDF viewer and +% often can also be saved together with the PDF. +% +% Currently the package doesn't initialize the font |/Helv| +% used by default in the fields (It works also without it, but this isn't fully compliant.) +% I don't want to setup the same font twice and haven't yet decided how +% to organize the collaboration with hyperref. So for now you should load hyperref +% and issue the \cs{Form} command. +% +% Please keep in mind +% \begin{itemize} +% \item Not every PDF viewer supports textfields. +% \item The font and the exact position of the chars depends on the PDF viewer. +% \item The handling can depend on settings in the PDF viewer. In adobe reader for +% example I had to disable an option to avoid that it tries to create an appearance +% itself +% \item Standards like pdf/A disable features of form fields too +% (as you typically can't change the PDF). +% \end{itemize} +% +% \subsection{About fonts} +% +% The font color and font size can be changed with the keys |fontcolor| and +% |fontsize| described below. This works quite reliably (but e.g. +% the PDF viewer of my browser insists to show the font in blue while editing). +% +% Much more difficult is the font family: +% a typical wish for textfields is that a font matching the document font is used +% in the fields. But how can that be done? +% Obviously it is not possible like with a checkbox to prepare and include appearances +% with the right look, the PDF reader has to render the text dynamically. + +% The PDF reference mentions only one way to pass a font setting to the text field: +% The |DA| key can contain a font operator and the fontname used should be added +% along with a object reference of the font to the form resources +% in the |AcroForm/DR/Font| dictionary. The question is: what does a PDF renderer +% make with this data? Clearly the main resources to render +% the text can not be to rely on an embedded font and a PDF font operator as both +% is not enough +% to guarantee a sensible text support: a font operator is normally used in +% the page stream along with glyph indices and positioning instructions, not +% with unicode input, and typically a font is only partially embedded. +% This means the PDF viewers and editors actually have to use external +% resources--system fonts, or fonts that come along with the viewer and libraries +% to handle font shaping. +% +% Hyperref may add a reference the type1 font helvetica to the DA key, but +% PDF viewers use actually Arial. And if one doesn't add a font with +% |DA| and |DR/Font| the text field works nevertheless. +% +% This doesn't mean that the DA/DR info is ignored altogether. +% Adobe Reader and Pro seems to use it to choose a fitting fallback font: +% \begin{itemize} +% \item One can change the font by simply using the font name (the examples use +% the |font| key of this module). One get courier with |font=courier|, +% times with |font=times|, +% comic sans with |font=ComicSansMS|, DejaVu with |font=DejaVuSans|. The fonts +% don't need to be used in the document or added as resources in the DR/Font dictionary. +% Some fonts work better than other: comic sans is quite unproblematic, +% but DejaVu seems to trigger a font search first and so is slower (perhaps the. +% \item If one fill and then save such a PDF at least adobe adds +% the missing font resources to the PDF. +% \end{itemize} +% +% This lazy font setting doesn't work with other PDF viewers. +% In other test I had better results by actually embedding a few glyphs +% of the font and then adding the font +% as resource to the DR/Font dictionary. Sadly this requires lualatex, only there is +% possible to retrieve the internal font name and font object number for a larger set +% of fonts---with pdflatex it works only for fonts not using a virtual font, and xelatex +% has no access at all. The code for lualatex looked like this (the font one wants +% to use should be active) +% \begin{verbatim} +% \pdffield_textfield:n {name=text,font=F\pdffeedback~fontname\font} +% \pdfmanagement_add:nxx{Catalog/AcroForm/DR/Font} +% {F\pdffeedback~fontname\font} +% {\pdffeedback~fontobjnum\font \c_space_tl 0 \c_space_tl R} +% \end{verbatim} +% +% \subsection{Vertical alignment} +% There is no way to set a reference point for the baseline. +% Alignment must achieved by +% fiddling with the height and depth of the field. The defaults (which uses as +% height the fontsize, and a bit depth) works okay in adobe reader with arial. +% If the font is set to courier, the text jumps up and one has to decrease the height +% by around 30\%. For a multiline field which should be top aligned you should +% increase the depth by the wanted amount \emph{and} the height by around 2pt. +% +% The geometry of the fields is seen by TeX, and so can influence the line spacing. +% If needed you should hide the height with \cs{raisebox} or \cs{smash}. +% +% \section{Textfields} +% Input a value: +% \ExplSyntaxOn +% \pdffield_textfield:n{name=test,width=4cm,height=0.7\baselineskip,depth=0.3\baselineskip} +% \ExplSyntaxOff +% +% \bigskip +% \subsection{Commands} +% \begin{function}{\pdffield_textfield:n} +% \begin{syntax} +% \cs{pdffield_textfield:n}\Arg{key val list} +% \end{syntax} +% This creates a textfield. The list of allowed keys is described below. +% The \meta{key val list} should at least set the name, without it the default name +% |textfield| is used. Textfields with the same +% name belong to the same field and are filled together. The default appearance +% is a light gray background. +% The default appearance is setup at the first use. +% \end{function} +% +% +% \subsection{Keys} +% +% The new textfield command accept all field and annot keys from l3pdffield, +% please check the documentation there. The list here mentions only a few +% central keys, and the keys which are either specific for textfields, or have +% changed functionality. +% +% Disabled keys are +% \begin{itemize} +% \item |FT| is overwritten. +% \item |DA| is overwritten. +% Locally use |fontcolor|, |fontsize| and |font| instead. +% Globally you can set the |DA| key in the catalog with for example +% \begin{verbatim} +% \pdfmanagement_add:nnn{Catalog/AcroForm}{DA}{(/Helv~10~Tf~1~1~0~rg)} +% \end{verbatim} +% \item For textfields only the field flags |ReadOnly|, |Required| |NoExport| +% |Multiline|, |Password|, |FileSelect|, |DoNotSpellCheck|, |DoNotScroll| and |Comb| +% make sense. +% If |Comb| is set, |Multiline|, |Password| and |FileSelect| are unset, |MaxLen| is +% set to 10 if it hasn't been set previously. +% \end{itemize} +% +% \begin{function}{preset-textfield} +% \begin{syntax} +% |preset-textfield| = \Arg{key-val-list} +% \end{syntax} +% This allows to set default keys for a textfield. +% \end{function} +% +% \begin{function}{name,T} +% \begin{syntax} +% |name| = \meta{partial name}\\ +% |T| = \meta{partial name} +% \end{syntax} +% This sets like the |T| key for fields the partial name of the field. The value +% shouldn't contain a period, be not empty and sensibly consist of simple chars. +% Additionally the value is used to create the field ID. +% This means that textfield with the same partial name are annotations +% with the same field as parent and are filled together---this +% what is typically expected. +% The field ID is then internal and can not be used to +% attach another annotation. +% For explicit control of the field ID use the |fieldID| key. +% \end{function} +% +% \begin{function}{fieldID} +% \begin{syntax} +% |fieldID| = \meta{field ID}\\ +% \end{syntax} +% \emph{For experts only!} +% This allows to give the textfield a specific ID. This is only useful +% in the context of a larger fieldset or if you want to attach another annotation +% to the field with \cs{pdffield_annot:n}. If used wrongly you can +% easily create an invalid fieldset. It allows you to create to fields with the +% same partial name, but if you want to see both +% you need to ensure that their full names are +% different---for example by adding some parent fields. +% \end{function} +% +% \begin{function}{parent} +% \begin{syntax} +% |parent| = \meta{field ID}\\ +% \end{syntax} +% This is only needed if the field should be part +% of a larger fieldset. The value should be a field ID of a field created previously +% with \cs{pdffield_field:nn}. +% \end{function} +% +% \begin{function}{altname,TU} +% \begin{syntax} +% |altname| = \meta{string}\\ +% |TU| = \meta{string}\\ +% \end{syntax} +% This is sets an alternative name for user interaction. +% This name can only be set at the first textfield instance, when the field is initialized. +% \end{function} +% +% \begin{function}{mappingname,TM} +% \begin{syntax} +% |mappingname| = \meta{string}\\ +% |TM| = \meta{string}\\ +% \end{syntax} +% This is sets an alternative name for export. +% This name can only be set at the first textfield instance, when the field is initialized. +% \end{function} +% +% \begin{function}{width,height,depth} +% \begin{syntax} +% |width| = \meta{dim expression}\\ +% |height| = \meta{dim expression}\\ +% |depth| = \meta{dim expression} +% \end{syntax} +% These keys allow to set the dimensions of textfield instance. +% The value should be a dimension expression. By default +% |width| is 3cm, the |height| uses the fontsize (\cs{f@size} in pt), +% the |depth| is 0.3\cs{f@size}. +% \end{function} +% +% \begin{function}{appearance,rollover-appearance,down-appearance} +% \begin{syntax} +% |appearance| = \meta{name}\\ +% |rollover-appearance| = \meta{name}\\ +% |down-appearance| = \meta{name} +% \end{syntax} +% This keys sets the normal appearance, the rollover appearance (when the +% mouse hovers over the textfield) and the down appearance (when the +% mouse clicks). They expect the name of an existing form Xobject as value. +% The initial value is |pdffield/textfield/default| +% for the normal appearance and shows a light gray background. +% The other appearance are not set by default (and it is quite unclear if they +% make sense for a textfield). +% \end{function} +% +% \begin{function}{fontcolor} +% \begin{syntax} +% |fontcolor| = \meta{color expression} \verb"|" [\meta{model}]\Arg{values}\\ +% \end{syntax} +% This is sets the color of font in the textfield. Internally currently RGB is used. +% The colors used in +% \meta{color expression} must be known to the \pkg{l3color} commands. +% The initial color is black. It is a \emph{field} setting, that means instances +% share the color. +% \end{function} +% +% \begin{function}{fontsize} +% \begin{syntax} +% |fontsize| = \meta{dim expression} +% \end{syntax} +% This is sets the size of the font in the textfield. +% The default value is the current font size (\cs{f@size} in pt). +% It is a \emph{field} setting, that means instances +% share the size. +% \end{function} +% +% \begin{function}{font} +% \begin{syntax} +% |font| = \meta{symbolic font name} +% \end{syntax} +% This is sets the font in the textfield. See the discussion at the begin of +% the documentation about some background. The default value is |Helv| and this +% name is setup if you load hyperref and issue the \cs{Form} command. +% The default value is the current font size (\cs{f@size} in pt). +% It is a \emph{field} setting, that means instances +% share the font. +% \end{function} +% +% \subsection{Using with hyperref} +% The \cs{TextField} command from hyperref also prints a label, something that the +% command here doesn't do. A redefinition like the following should allow \cs{TextField} +% to use the commands of this module. Be aware that the behaviour will not be identical! +% Not every setting and key from \pkg{hyperref} has been copied. +% +% \begin{verbatim} +% \ExplSyntaxOn\makeatletter +% \def\@TextField[#1]#2{\LayoutTextField{#2}{\pdffield_textfield:n {name=#2,#1}}} +% \ExplSyntaxOff\makeatother +% \end{verbatim} +% +% +% \end{documentation} +% +% \begin{implementation} +% \section{\pkg{l3pdffield-textfield} Implementation} +% \begin{macrocode} +%<*package> +%<@@=pdffield> +% \end{macrocode} +% \subsection{Variables} +% \begin{macrocode} +\tl_new:N \l_@@_DA_fontcolor_tl +\dim_new:N \l_@@_DA_fontsize_dim +\tl_new:N \l_@@_DA_fontname_tl +% \end{macrocode} +% \subsection{Messages} +% \begin{macrocode} +% \end{macrocode} +% \subsection{Appearances} +% The default appearances are a cross (\cs{texttimes}), +% Every appearance should have two versions and follow the naming +% module/\meta{name}/Yes and module/\meta{name}/Off. +% \begin{macro}{@@/textfield/default_appearances:} +% This defines the standard appearance. It is setup at the first +% use of a textfield. +% \begin{macrocode} +\cs_new_protected:cn {@@/textfield/default_appearance:} + { + \pdffield_appearance:nn {pdffield/textfield/default} + { + { \color_select:n{black!5!white}\rule{\paperwidth}{\paperheight} } + } + \cs_gset_eq:cN {@@/textfield/default_appearance:} \prg_do_nothing: + } +% \end{macrocode} +% \end{macro} +% +%\subsection{Creating the field} +% A field should be created if the name doesn't exist +% \begin{macrocode} +\cs_new_protected:Npn \@@_textfield_field:n #1 %name + { + \pdf_object_if_exist:nF {@@/field/@@/textfield/#1} + { + \@@_field:n { @@/textfield/#1 } + } + \keys_set:nn {pdffield}{parent=@@/textfield/#1} + } +\cs_generate_variant:Nn \@@_textfield_field:n {V} +% \end{macrocode} +% \subsection{Assembling the textfield} + +% \begin{macro}{\@@_textfield:n} +% \begin{macrocode} +\cs_new_protected:Npn \@@_textfield:n #1 + { + \group_begin: + \cs_set_eq:NN\@@_value_handler:nN \@@_textfield_value_handler:nN + \use:c {@@/textfield/default_appearance:} +% \end{macrocode} +% Setting up the defaults. +% \begin{macrocode} + \keys_set:nn {pdffield} + { + ,fieldID= + ,name=textfield + ,appearance = pdffield/textfield/default + ,width = 3cm + ,fontsize= \f@size pt + ,height = \f@size pt, + depth = \fp_eval:n {0.3*\f@size} pt, + % font defaults!! + } +% \end{macrocode} +% \begin{macrocode} + \keys_set:nn { pdffield }{@@/preset/textfield,#1} + \int_compare:nNnT {\bitset_item:Nn \l_@@_Ff_bitset {Comb}}={1} + { + % warning if set? + \keys_set:nn { pdffield } + { + ,unsetFf={FileSelect,Multiline,Password} + } + \pdfdict_get:nnN {l_@@/field}{MaxLen}\l_@@_tmpa_tl + \quark_if_no_value:NT \l_@@_tmpa_tl + { + \keys_set:nn { pdffield} + { + MaxLen = 10 %variable + } + % warning + } + } + \keys_set:nn { pdffield } + { + ,FT= Tx + ,AS= + ,DA= + { + \pdf_name_from_unicode_e:n{\l_@@_DA_fontname_tl} + \c_space_tl + \dim_to_decimal_in_bp:n{\l_@@_DA_fontsize_dim} + \c_space_tl + Tf + \c_space_tl + \l_@@_DA_fontcolor_tl + \c_space_tl + %\l_@@_text_DAextra_tl + } + } + \tl_if_empty:NT\l_@@_fieldID_tl + { + \pdfdict_get:nnN {l_@@/field}{T}\l_@@_fieldID_tl + \tl_put_left:Nn \l_@@_fieldID_tl {@@/textfield/} + } + + \@@_textfield_field:V\l_@@_fieldID_tl + \@@_annot: + \group_end: + } +% \end{macrocode} +% \end{macro} +% +% \subsection{Keys} +% Most keys are inherited simply the ones from the generic field and annot keys. +% A key to decide if the box is initially checked or not. +% We stay in the same family so that we can build a style. +% \begin{macrocode} +\keys_define:nn {pdffield} + { + ,fontcolor .code:n = + { + \@@_color_set:nn {@@/tmp}{#1} + \color_export:nnN{@@/tmp}{space-sep-rgb}\l_@@_DA_fontcolor_tl + \tl_put_right:Nn \l_@@_DA_fontcolor_tl{~rg} + } + ,fontcolor .initial:n = black, + ,fontcolor .groups:n = {textfield} + ,font .tl_set:N = \l_@@_DA_fontname_tl + ,font .initial:n = {Helv} + ,font .groups:n = {textfield} + ,fontsize .dim_set:N = \l_@@_DA_fontsize_dim + ,fontsize .initial:n = {10bp} + ,fontsize .groups:n = {textfield} + } +% \end{macrocode} +% And a key to set a dedicated field ID +% \begin{macrocode} +\keys_define:nn { pdffield } + { + fieldID .tl_set:N = \l_@@_fieldID_tl + } +% \end{macrocode} +% +% \subsection{Handler} +% \begin{macrocode} +\cs_new_protected:Npn \@@_textfield_value_handler:nN #1#2 + { + \pdf_string_from_unicode:nnN {utf8/string}{#1}#2 + } +% \end{macrocode} +% +% \subsection{user commands} +% \begin{macro}{\pdffield_textfield:n} +% \begin{macrocode} +\cs_set_eq:NN \pdffield_textfield:n \@@_textfield:n +%</package> +% \end{macrocode} +% \end{macro} +%\end{implementation} diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.pdf Binary files differnew file mode 100644 index 0000000000..69a2e13b7d --- /dev/null +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield.dtx index dc3fcc3df6..e1e5f8bae1 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3pdfpdffield-checkbox.dtx +%% File: l3pdffield.dtx % % Copyright (C) 2021 The LaTeX Project % @@ -28,9 +28,9 @@ \makeatletter \declare@file@substitution{doc.sty}{doc-v3beta.sty} \makeatother -\documentclass[full]{l3doc} -\usepackage{array,booktabs} -\usepackage{l3pdffield-testphase,bearwear} +\documentclass{l3doc} +\usepackage{array,booktabs,caption} +\usepackage{l3pdffield-testphase,tikz} \hypersetup{pdfauthor=The LaTeX Project, pdftitle=l3pdffield (LaTeX PDF management testphase bundle)} \begin{document} @@ -43,17 +43,22 @@ % idxtype = {checkbox key}, % printtype= \textit{checkbox key} % ]{Checkboxkey}{checkboxkey} +% \NewDocElement[ +% idxgroup=field keys, +% idxtype = {field key}, +% printtype= \textit{field key} +% ]{Fieldkey}{fieldkey} +% \NewDocElement[ +% idxgroup=setup keys, +% idxtype = {setup key}, +% printtype= \textit{setup key} +% ]{Fieldsetupkey}{fieldsetupkey} +% \NewDocElement[ +% idxgroup=annot keys, +% idxtype = {annot key}, +% printtype= \textit{annot key} +% ]{Annotkey}{annotkey}% % \providecommand\hook[1]{\texttt{#1}} -% \ExplSyntaxOn -% \pdffield_store_appearance:nn {bear/Yes} -% { -% \tikz\bear\bearwear[shirt=red,body~deco={\node[font=\tiny\bfseries,white]~at~(beartummy){Yes};}]; -% } -% \pdffield_store_appearance:nn {bear/Off} -% { -% \tikz\bear\bearwear[body~deco={\node[font=\tiny\bfseries,white]~at~(beartummy){Off};}]; -% } -% \ExplSyntaxOff % \title{^^A % The \pkg{l3pdffield} module\\ Commands to create form fields ^^A % \\ \LaTeX{} PDF management testphase bundle @@ -68,36 +73,50 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} % \section{\pkg{l3pdffield} Introduction} -% The implementation of form fields in hyperref has some bugs, see for example -% \url{https://github.com/latex3/hyperref/issues/94}. This package is a first step +% The implementation of form fields in hyperref has some bugs\footnote{see for example +% \url{https://github.com/latex3/hyperref/issues/94}}. This package is a first step % towards the goal to review and improve the code of form fields. % % Like the \pkg{pdfmanagement-testphase} package itself it is a temporary package: -% the definite home of the code is not yet decided. +% the definite home of the code is not yet decided, and during the development +% changes in the interfaces are possible. % -% It handles for now \emph{only} checkboxes, other form fields like pushbutton, -% radio buttons or text fields will follow later. As currently no fonts are used, -% it doesn't relies on the hyperref code -% to initialize the form, but it can be used with hyperref. +% The package itself is currently loaded with +% \begin{verbatim} +% \usepackage{l3pdffield-testphase} +% \end{verbatim} % -% The code requires the new PDF management. The code makes use of -% \pkg{l3pdfxform} to create the Xobjects. This code doesn't support yet the -% the dvips backend. +% The code is splitted into various submodules. \texttt{l3pdffield} +% contains the basic commands to create a form field. The code related to field types +% like checkboxes are in \texttt{l3pdffield-\emph{type}}, for example +% \texttt{l3pdffield-checkbox}. Currently only checkboxes have been implemented, +% other form fields like pushbutton, +% radio buttons or text fields will follow later. +% The code doesn't rely on to initialize the form, +% but it can be used with hyperref. % +% The code requires the new PDF management. The code makes use of +% \pkg{l3pdfxform} to create the form Xobjects of the appearances. +% This code doesn't support yet the the dvips backend. % +% The code targets PDF~2.0. This doesn't mean that it won't work in older +% PDF versions, but it tries to implement requirements needed or recommended +% for 2.0; most importantly appearances are used by default everywhere and it +% deprecates |/NeedAppearances|. % % Please keep in mind % \begin{itemize} -% \item Not every PDF viewer supports checkboxes. +% \item Not every PDF viewer supports form fields or all types and features. % \item The handling can depend on settings in the PDF viewer. In adobe reader for % example I had to disable an option to avoid that it tries to create an appearance -% itself -% \item Standards like pdf/A disable form fields too (as you typically can't change the PDF). +% itself. +% \item Standards like pdf/A disable some features of form fields like javascript actions +% (as you typically can't change the PDF). % \end{itemize} % % If \pkg{hyperref} is loaded before @@ -115,258 +134,636 @@ % \begin{document} % \Form % \end{verbatim} -% \section{Step 1: Checkboxes} -% Click me: -% \ExplSyntaxOn\pdffield_checkbox:n{name=bear,appearance=bear,width=23pt,height=30pt,depth=10pt}\ExplSyntaxOff % -% \bigskip -% \subsection{Commands} -% \begin{function}{\pdffield_checkbox:n} +% \section{Some background} +% +% A document can contain a arbitrary number of fields which can be organized in trees. +% The leaf fields in such a tree, the \emph{terminal fields}, typically have +% widget annotations as kids which are then the actual, visual instances of the field, +% and allow to interact with the field. I will call such a +% tree a \emph{fieldset}, nodes \emph{fields} and the widget annotation +% \emph{field annotations}. +% +% If a field has only one child annotation the content of the field dictionary and the +% widget annotation dictionary can be merged---some examples in the PDF reference +% show such merged dictionaries---but the code here keeps them separate, at the end +% this is clearer. +% +% A simple example would look like this +% +% \begin{tikzpicture}[level 2/.style={level distance=7mm}, +% level 1/.style={sibling distance=25mm}, +% level 2/.style={sibling distance=15mm}] +% \node[draw] {week} +% child {node[draw] {mon} +% child {node[draw,dashed] {annot}} +% } +% child {node[draw] {tue} +% child {node[draw,dashed] {annot}} +% } +% child {node[draw] {wen} +% child {node[draw,dashed] {annot}} +% child {node[draw,dashed] {annot}} +% } +% ; +% \end{tikzpicture} +% +% In many cases a fieldset consists of only one field along with its field annotation(s), +% but larger sets can be needed to build more complex interactions with javascript code. +% For example a datepicker can be built as a fieldset with various fields to represent +% the month and year choice and to select days. +% +% Fields in a fieldset should have a name, for example |wen| or |week| in the example +% above. This name is the \emph{partial name} of the field, the \emph{full name} +% is than built from it by adding the names of the parents separated by periods. +% In the example above the partial name is \texttt{mon} and the full name +% \texttt{week.mon}. +% Partial names shouldn't contain periods. If two fields have the same name they will +% work in unison: if you enter text in one field, the text appears also in the other, such +% fields must have the same type and the same value and default value entry. +% If a field has no name it is considered to be a simple widget annotation and so +% only another representation of its parent. +% +% +% All terminal fields should also have a type, e.g. \texttt{Btn} for a button field, +% or \texttt{Tx} for a textfield. The type can be set for the parent and then inherited. +% The fields in a fieldset can have different types. +% +% \subsection{The look of a field: Appearances and other settings} +% +% The look of widget annotation of a field can be set with various keys. The keys developed over +% time and some of them superseed older ones. There is for example the simple +% |/Border|, the more sophisticated |/BS| (\enquote{border style dictionary}), +% the \enquote{dynamic appearance dictionary} |MK|, with lots of keys, +% and the appearance dictionary |/AP| which +% may define as many as three separate appearances: +% the normal appearance (required), the rollover appearance and the down appearance. +% Such an appearance can be a simple form XObjects% +% \footnote{Such form XObjects are small pictures stored in the PDF which +% can be referenced in various part of the PDF. They can be +% created with the commands of the \pkg{l3pdfxform} package.}% +% , but in some cases the annotation can have different \emph{appearance states}: +% a checkbox +% for example can be checked or unchecked, in this case the appearances +% are dictionaries which +% maps state names like |/Yes| and |/Off| to form XObjects. +% +% The annotations cover a rectangular area on +% the page and form XObjects appearances are squeezed into this rectangle. +% So for the best result +% both should have the same ratio of width and height. Simple plain backgrounds can +% also be created in large size and reused for various annotations. +% Form XObjects used as appearances can not be rotated, if needed one has to +% create a new appearance. +% +% +% In PDF 2.0 widget annotations must have at least a normal |/AP| appearance +% (unless the size of the annotation is zero) and the keys \enquote{\itshape C, IC, Border, +% BS, BE, BM, CA, ca, H, DA, Q, +% DS, LE, LL, LLE, and Sy shall be ignored}. But it is quite unclear if +% PDF Viewer honor this, and if this make sense e.g. for text fields which require +% a DA entry. It is also not clear how appearances and the entries of the MK dictionary +% are related in a form field. Tests with some PDF viewers +% are needed here. +% +% +% \section{Commands} +% \begin{function}{\pdffield_field:nn,\pdffield_field:Vn} % \begin{syntax} -% \cs{pdffield_checkbox:n}\Arg{key val list} +% \cs{pdffield_field:nn}\Arg{key val list}\Arg{field ID} % \end{syntax} -% This creates a checkbox to check and uncheck. The list of allowed keys is described below. -% Typically the \meta{key val list} should at least set the name. Checkboxes with the same -% name belong to the same field and are checked and unchecked together. The default appearance -% is a quadratic frame with a \cs{texttimes} in it for the checked case. +% This creates a new field. \meta{field ID} will be used to create and +% reference the needed objects but it is not the direct object name, so +% |pdf_object_ref:n| can not be used to access (and there will not +% clash with object names). It is recommended to start +% the name with a module prefix to avoid name clashes, so e.g. |mymodule/field/1| or +% |mymodule/field/week|. +% +% The list of handled keys is described below. +% Typically the \meta{key val list} should at least set the name |T|, fields that +% are kids in a fieldset must set the |parent| key, this should point to a field +% declared before. +% +% The command is meant as a basic command to build more complex variants like +% checkbox or textfields. For this reason it doesn't check if +% the combination of values and flags are sensible, and it uses as key names the +% names from the PDF reference. +% If you create a button field (Btn) and set MaxLen (which is only known for text +% fields), it will not complain. +% +% Root fields (fields without parent) are added automatically to the +% Catalog/AcroForm dictionary with +% +% +% \begin{verbatim} +% \pdfmanagement_add:nnx{Catalog/AcroForm}{Fields}{<obj ref>} +% \end{verbatim} +% % \end{function} % -%\begin{function}{\pdffield_setup:nn} +% \begin{function}{\pdffield_annot:n,\pdffield_annot:V} % \begin{syntax} -% \cs{pdffield_setup:nn}\Arg{field type}\Arg{key val list} +% \cs{pdffield_field:nn}\Arg{key val list} % \end{syntax} -% This allows to setup up values for following fields. \Arg{field type} -% should be a field, currently the only allowed value is |checkbox|. +% This creates a new field annotation. +% It is a widget annotation box created with \cs{pdfannot_widget_box:nnn}, and +% it is possible to add values to its dictionary +% by using |\pdfannot_dict_put:nnn {widget}...|. +% But to correctly setup the parent/kid relationship some additional wrapper code is needed. +% The command also setup dictionaries to fill the |AP|, |MK| and |AA| dictionaries. % \end{function} % -%\begin{function}{\pdffield_store_appearance:nn} +% \begin{function}{\pdffield_appearance:nn} % \begin{syntax} -% \cs{pdffield_store_appearance:nn}\Arg{name/state}\Arg{content} +% \cs{pdffield_appearance:nn}\Arg{name}\Arg{content} % \end{syntax} -% This is a small wrapper around \cs{pdfxform_new:nn} and store appearances for the fields. -% \meta{state} should be for checkboxes either |Yes| or |Off| (and typically -% you should define both). \meta{name} is the name -% that is used in the |appearance| key, |checkbox/default| is predefined and so can't be used. -% \meta{content} is arbitrary content. The dimensions should fit to the planed size of the -% checkbox.% +% This is a small wrapper around \cs{pdfxform_new:nnn} (which could be used too) +% to create an appearance. To avoid name clashes \meta{name} should start with +% a module part, e.g. |mymodule/appearance/cross|. % \end{function} -% \subsection{Keys} % -% The new checkbox commands accepts following keys: +% \begin{function}{\pdffield_setup:n} +% \begin{syntax} +% \cs{pdffield_setup:n}\Arg{key-val} +% \end{syntax} +% This command allows to preset some field settings. +% \end{function} +% It knows currently two keys: % -% \DescribeCheckboxkey{name} This sets the (internal) name of the field. It shouldn't contain -% a period, be not empty and sensibly consist of simple chars. Checkboxes instances -% with the same name belong to the same field and are checked and unchecked together. +% \begin{function}{create-style} +% \begin{syntax} +% |create-style| = \Arg{name}\Arg{key-val} +% \end{syntax} +% This defines a style which can then be used with the |style| key. +% \Arg{key-val} can be an arbitrary collection of the keys of the module. +% \end{function} % -% \DescribeCheckboxkey{altname} This sets an alternative name for user interaction. -% This name can only be set at the first checkbox instance, when the field is initialized. -% \DescribeCheckboxkey{mappingname} This sets an alternative name for export. -% This name can only be set at the first checkbox instance, when the field is initialized. +% \begin{function}{preset-checkbox} +% \begin{syntax} +% |preset-checkbox|=\Arg{key-val} +% \end{syntax} +% This allows to set default keys for a checkbox. +% \end{function} + +% \section{Field Keys} +% +% Table~\ref{tab:fieldkeys} summarize the keys which can be used. +% A number of keys have two names, the second is normally the name used by hyperref. +% Where is makes sense an empty value \enquote{unsets} a key. +% +% \begin{table} +% \caption{Keys for fields}\label{tab:fieldkeys} +% \centering +% \begin{tabular}{>{\ttfamily}lllll} +% \toprule +% key & value & required & inheritable &remark\\\midrule +% parent & field ID & for non-root fields & \\ +% style & style name & & defined with |create-style| \\ +% T, name & string & mostly & \\ +% TU, altname & string & & \\ +% TM, mappingname & string & & \\ +% FT & name & terminal fields & yes \\ +% setFf, & list of flags & & yes\\ +% setfieldflags\\ +% unsetFf, & list of flags & & yes \\ +% unsetfieldflags \\ +% V & various & & yes \\ +% DV & various & & yes \\ +% MaxLen & integer & with Comb & yes & only textfields\\ +% Lock & object name & & & signature field\\ +% SV & object name & & & signature field\\ +% Opt & object name & & & buttons and choice fields\\ +% TI & integer & & & list fields\\ +% I & object name& & & list fields\\ +% AA/K, keystroke & javascript \\ +% AA/F, format & javascript\\ +% AA/V, validate & javascript\\ +% AA/C, calculate & javascript\\ +% DA & string & yes & yes & variable text \\ +% Q & 0, 1 or 2 & & yes &variable text \\ +% DS & & & & (ignored) \\ +% RV & & & & (ignored) \\\bottomrule +% \end{tabular} +% \end{table} +% +% \begin{function}{parent} +% \begin{syntax} +% |parent| = \meta{field ID}\\ +% \end{syntax} +% This declares the parent of the field. It is required if +% the field is not the root of the fieldset. The value is the field ID +% of the parent, the parent should have been already declared. +% It will add the reference to the parent field to the |/Parent| key, and also +% add reference of the kid as |/Kid| in the parent field. +% \end{function} % -% \DescribeCheckboxkey{width} -% \DescribeCheckboxkey{height} -% \DescribeCheckboxkey{depth} These keys allow to set the dimensions of checkbox instance. -% The value should be a command that expands to a dimension expression. By default -% |width| and |height| use \cs{normalbaselineskip}, the |depth| is zero. -% -% \DescribeCheckboxkey{appearance} This key sets the normal appearance. It takes as value a -% \meta{name} and expects that the two appearances \meta{name}|/Yes| and \meta{name}|/Off| -% has been created with the command described below. The initial value is |checkbox/default| -% and shows a \cs{texttimes}. -% -% \DescribeCheckboxkey{rollover-appearance} This key sets the rollover appearance (when the -% mouse hovers over the checkbox). It takes as value a -% \meta{name} and expects that the two appearances \meta{name}|/Yes| and \meta{name}|/Off| -% has been created with the command described below. Initially this is not set. -% An empty value removes the entry. -% -% \DescribeCheckboxkey{down-appearance} This key sets the down appearance (when the -% mouse clicks). It takes as value a -% \meta{name} and expects that the two appearances \meta{name}|/Yes| and \meta{name}|/Off| -% has been created with the command described below. Initially this is not set. -% An empty value removes the entry. -% -% \DescribeCheckboxkey{checked} This is a boolean key which allows to set if the -% checkbox should be initially checked or not. It sets the |/V| and |/DV| key of the field -% and the |/AS| key of the annotation instance. It is possible to use different -% values for different instances, if one wants to confuse the user. -% -% \DescribeCheckboxkey{setfieldflags} -% \DescribeCheckboxkey{unsetfieldflags} -% These keys allow to set or unset the field flags. They expect a comma lists of -% flag names. Allowed names |ReadOnly|, |Required|, +% \begin{function}{name,T} +% \begin{syntax} +% |name| = \meta{partial name}\\ +% |T| = \meta{partial name} +% \end{syntax} +% This sets the partial name of the field. It shouldn't contain +% a period, be not empty and sensibly consist of simple ascii chars. +% It is normally required, see above. The value is passed through \cs{pdf_string_from_unicode:nnN}. +% \end{function} +% +% \begin{function}{altname,TU} +% \begin{syntax} +% |altname| = \meta{string}\\ +% |TU| = \meta{string}\\ +% \end{syntax} +% This sets an alternative name for user interaction. +% Unlike the name field it can use unicode or periods. +% The value is passed through \cs{pdf_string_from_unicode:nnN} +% \end{function} +% +% \begin{function}{mappingname,TM} +% \begin{syntax} +% |mappingname| = \meta{string}\\ +% |TM| = \meta{string}\\ +% \end{syntax} +% This sets an alternative name for the export. +% The value is passed through \cs{pdf_string_from_unicode:nnN} +% \end{function} +% +% \begin{function}{mappingname,TM} +% \begin{syntax} +% |FT| = |Btn|\verb"|"|Tx|\verb"|"|Ch|\verb"|"|Sig| +% \end{syntax} +% This sets the type of the field, the value should be one of +% \texttt{Btn} (button), \texttt{Tx} (text), \texttt{Ch} (choice), \texttt{Sig} (signature). +% The value is of relevance only for terminal fields, but it can be set in a parent +% and then inherited. +% \end{function} +% +% \begin{function}{setfieldflags,setFf,unsetfieldflags,unsetFf} +% \begin{syntax} +% |setfieldflags| = \meta{comma list of flags}\\ +% |setFf| = \meta{comma list of flags}\\ +% |unsetfieldflags| = |all| \verb"|" \meta{comma list of flags}\\ +% |unsetFf| = |all| \verb"|" \meta{comma list of flags} +% \end{syntax} +% These keys accept a list of flag names and then sets or unsets them, the resulting value +% is then used with the \texttt{/Ff} key. Depending +% on the field type some flags must be set or unset, other are optional or are ignored. +% The flag name can be given in PDF spelling (\texttt{RadiosInUnison}), +% in lowercase (\texttt{radiosinunison}), and as number. |unsetFf| and its +% alias |unsetfieldflags| know the special value |all| which clears all the fields. +% +% The list of flags are: +% |ReadOnly|, |Required|, % |NoExport|, |Multiline|, |Password|, |NoToggleToOff|, |Radio|, |Pushbotton|, % |Combo|, |Edit|, |Sort|, |FileSelect|, |MultiSelect|, |DoNotSpellCheck|, % |DoNotScroll|, |Comb|, |RadiosInUnison|, |RichText|, |CommitOnSelChange|. % -% From these |Radio|, |Pushbotton| are set automatically automatically by the code -% as this is required for a checkbox. Not every one from the rest makes sense for -% checkboxes but the same key will be used for other fields too. -% Check the PDF reference to decide which one to set or unset. -% -% \begin{checkboxkey}{keystroke,format,validate,calculate} -% These keys add the |/K, |/F, |/V|, |/C| key to the |/AA| dictionary of the field object. -% Their value should be javascript code. The |/AA| dictionary is suppressed -% if a pdf/A standard is set. These keys are probably not of much used with a checkbox. -% \end{checkboxkey} -% -% \vspace{2\baselineskip} -% \begin{checkboxkey}{onfocus,onblur,onmousedown,onmouseup,onenter,onexit} -% These keys adds the |/F, |/Bl, |/D|, |/U|, |E| and |X| key to the |/AA| dictionary -% of the widget annotation (the checkbox instance) object. -% Their value should be javascript code. The |/AA| dictionary -% is suppressed if a pdf/A standard is set. +% \end{function} % -% For example -% \begin{verbatim} -% onenter={app.alert('Hello');} -% \end{verbatim} -% \end{checkboxkey} +% \begin{function}{V} +% \begin{syntax} +% |V| = \meta{various} +% \end{syntax} +% This sets the value of the field. Its +% format varies depending on the field type, so typically +% commands for the various type will have to preprocess and sanitize it. +% The value given here is x-expanded and then added to the dictionary! +% See the descriptions of individual field types for further information. +% (Pushbuttons for example don't have a value). +% \end{function} % -% \subsection{Using with hyperref} -% The \cs{CheckBox} command from hyperref also prints a label, something that the -% command here don't do. A redefinition like the following should allow to \cs{CheckBox} -% to use the commands of this module. Be aware that the behaviour will not be identical! -% Not every setting and key from \pkg{hyperref} has been copied. +% \begin{function}{DV} +% \begin{syntax} +% |DV| = \meta{various} +% \end{syntax} +% The default value, to which the field reverts +% when a reset-form action is executed. The format of this value is the +% same as that of \texttt{DV}. +% \end{function} % -% \begin{verbatim} -% \ExplSyntaxOn\makeatletter -% \def\@CheckBox[#1]#2{\LayoutCheckField{#2}{\pdffield_checkbox:n {name=#2,#1}}} -% \ExplSyntaxOff\makeatother -% \end{verbatim} +% \begin{function}{MaxLen} +% \begin{syntax} +% |MaxLen| = \meta{integer} +% \end{syntax} +% Only relevant for textfields. +% The value is an integer and describes the maximum length of the field’s text in characters. +% Required if the |Comb| flag is used. +% \end{function} % -% \subsection{Some background} -% Form fields consist of a field object and number of instances of the field: -% A checkbox can appear on more than one page or location and if one instance -% is checked all other instances follows and are checked too. -% -% All instances are in this case widget annotations and are referenced in the Kid array of the field -% object\footnote{Fields can actually build a tree: between the root field and -% widget annotations there can be more fields. The last one before the widget is -% the \emph{terminal} field, but unless a sensible -% use case comes up, I will assume that the widget annotations are direct children of -% the root and that the root field is the terminal field.}. -% This means that the code has to collect all the children and write -% out the field object at the end of the document. -% -% If a field has only one children the content of the field dictionary and the -% widget annotation dictionary can be merged---some examples in the PDF reference -% show such merged dictionaries---but the code here keeps them separate, at the end -% this is clearer. +% \begin{function}{Lock} +% \begin{syntax} +% |MaxLen| = \meta{object name} +% \end{syntax} +% Only relevant for signature fields. The value is an object name +% which should point to a dictionary that specifies a set of form fields +% that shall be locked when this signature field is signed. The exact format of +% the dictionary is described in the PDF reference. +% \end{function} % -% All the root field objects must be referenced in the AcroForm dictionary in the -% Fields entry. This can be done with +% \begin{function}{SV} +% \begin{syntax} +% |SV| = \meta{object name} +% \end{syntax} +% Only relevant for signature fields. The value is an object name +% which should point to a seed value dictionary. The exact format of +% the dictionary is described in the PDF reference. +% \end{function} % -% \begin{verbatim} -% \pdfmanagement_add:nnx{Catalog/AcroForm}{Fields}{<obj ref>} -% \end{verbatim} +% \begin{function}{Opt} +% \begin{syntax} +% |Opt| = \meta{object name} +% \end{syntax} +% Only relevant for checkboxes, radiobuttons and choice fields. +% The value is an object name +% which should point to a array. The exact format of +% the array is described in the PDF reference. +% \end{function} % -% A checkbox has two different looks: checked and unchecked. The current hyperref -% implementation uses symbolic names for the two states and and adds some -% values with the /MK key and lets the PDF viewer -% create a look from them. But this doesn't work reliably. Also newer PDF versions -% deprecate the /NeedAppearances setting and require that such a look, -% an \enquote{appearance}, is given as form XObjects: -% such form XObjects are like small pictures stored in the PDF and can be referenced -% in various part of the PDF. They can be created with the commands of -% the \pkg{l3pdfxform} package. -% -% The checkbox instances---the widget annotations---cover a rectangular area on -% the page, the XObjects are squeezed into this rectangle. So for the best result -% both should have the same ratio of width and height. -% XObjects used as appearances can not be rotated, if needed one has to -% create a new appearance. +% \begin{function}{TI} +% \begin{syntax} +% |TI| = \meta{integer} +% \end{syntax} +% Only relevant for scrollable list boxes. +% The value is an integer, the top index (the index in the Opt array +% of the first option visible in the list). Default value: 0 +% \end{function} % -% \subsubsection{The field dictionary} +% \begin{function}{I} +% \begin{syntax} +% |I| = \meta{object name} +% \end{syntax} +% For choice fields that allow +% multiple selection (MultiSelect flag set). The value is an object name +% which should point to a array. The exact format of +% the array is described in the PDF reference +% (I have no idea what exactly should be added there, perhaps some future test will make +% it more understandable.) +% \end{function} % -% The field dictionary shall or can have the following entries +% The following four keys are used to add javascript (\enquote{ECMAScript}) code. +% The values are currently only passed through \cs{pdf_string_from_unicode:nnN}, +% but this perhaps will have to change. The keys will be ignored if a pdfstandard +% is used that prohibits such actions. +% +% \begin{function}{AA/K,keystroke} +% \begin{syntax} +% |AA/K| = \meta{string (ECMAScript)}\\ +% |keystroke| = \meta{string (ECMAScript)} +% \end{syntax} +% This adds a keystroke action to the +% additional action dictionary. The value is passed through +% \cs{pdf_string_from_unicode:nnN}. The action is meant for text and choice fields. +% It is quite unclear if such an action +% make sense for non-terminal fields. +% \end{function} +% +% \begin{function}{AA/F,format} +% \begin{syntax} +% |AA/F| = \meta{string (ECMAScript)}\\ +% |format| = \meta{string (ECMAScript)} +% \end{syntax} +% This adds a format action to the +% additional action dictionary. The value is passed through +% \cs{pdf_string_from_unicode:nnN}. The action is meant for text and choice fields. +% It is quite unclear if such an action +% make sense for non-terminal fields. +% \end{function} % -% \begin{description} -% \item[FT] required for terminal fields (here for the root field), -% the value is always \texttt{Btn}, so this entry is set by the code. -% \item[Parents] currently irrelevant as we don't have a field hierarchy. -% \item[Kids] an array. Contains references to the children, in our case to -% the widget annotations. The array is build by the code. +% \begin{function}{AA/V,validate} +% \begin{syntax} +% |AA/V| = \meta{string (ECMAScript)}\\ +% |validate| = \meta{string (ECMAScript)} +% \end{syntax} +% This adds a validate action to the +% additional action dictionary. The value is passed through +% \cs{pdf_string_from_unicode:nnN}. It is quite unclear if such an action +% make sense for non-terminal fields. +% \end{function} +% +% \begin{function}{AA/C,calculate} +% \begin{syntax} +% |AA/C| = \meta{string (ECMAScript)}\\ +% |calculate| = \meta{string (ECMAScript)} +% \end{syntax} +% This adds a calculate action to the +% additional action dictionary. The value is passed through +% \cs{pdf_string_from_unicode:nnN}. It is quite unclear if such an action +% make sense for non-terminal fields. +% \end{function} % -% \item[T] required, the name, a (unique) text string without a period. -% This field is a mandatory argument which must be given by the user. -% The value should be passed through a suitable string conversion and checked -% if it contains a period (which is not allowed). +% \begin{function}{DA} +% \begin{syntax} +% |DA| = \meta{string} +% \end{syntax} +% This contains instructions for the text in text fields. +% It is stored expanded and parentheses are added around the value. +% \end{function} % -% \item[TU,TM] optional, alternative names for user messages (TU) and export (TM). -% As these fields are optional they should be set by some key-val option. +% \begin{function}{Q,align} +% \begin{syntax} +% |Q| = |left|\verb"|"|center|\verb"|"|right|\\ +% |align| = |left|\verb"|"|center|\verb"|"|right| +% \end{syntax} +% The justification of the text. +% \end{function} % -% \item[Ff] A bitset, two flags must be unset for a checkbox (Radio and Pushbotton), -% for the rest we need a keyval interface. +% \begin{function}{DS,RV} +% These two keys are currently not implemented +% as it is unclear if there are of any use. +% \end{function} % -% \item[V] describes the initial value, for checkboxes is should be either |/Yes| -% or |/Off|. The initial value will be |/Yes|, keys are need to set both the local -% and the default value. +% \section{Annot keys} +% +% Table~\ref{tab:annotkeys} summarize the keys which can be used. +% A number of keys have alias names which are mentioned in the descriptions. +% +% \begin{table} +% \caption{Keys for field annotations}\label{tab:annotkeys} +% \centering +% \begin{tabular}{>{\ttfamily}lllll} +% \toprule +% key & value & required &remark\\\midrule +% parent & field ID & yes \\ +% width & dim expression & (yes) & default is 0pt \\ +% height & dim expression & (yes) & default is 0pt \\ +% depth & dim expression & (yes) & default is 0pt \\ +% AP/N & appearance name & yes (in PDF 2.0) \\ +% AP/R & appearance name & yes (in PDF 2.0) \\ +% AP/D & appearance name & yes (in PDF 2.0) \\ +% AS & name & yes (in PDF 2.0) \\ +% setF & list of flags \\ +% unsetF & list of flags \\ +% AA/* & javascript & *= F, Bl, D, U, E, \\ +% & & X, PO, PC,PV, PI\\ +% MK/* & various & *= R, BC, BG, CA, RC, \\ +% & & AC, I, RI, IX, IF, TP\\ \bottomrule +% +% \end{tabular} +% \end{table} +% +% \begin{function}{width,height,depth} +% \begin{syntax} +% |width| = \meta{dim expression}\\ +% |height| = \meta{dim expression}\\ +% |depth| = \meta{dim expression} +% \end{syntax} +% These keys allow to set the dimensions of the annotation. +% The value should be a command that expands to a dimension expression. By default +% all values are zero. +% \end{function} +% +% \begin{function}{parent} +% \begin{syntax} +% |parent| = \meta{field ID}\\ +% \end{syntax} +% This sets the parent. The value should be field ID of +% an already declared field. +% \end{function} +% +% \begin{function}{AP/N,AP/R,AP/D} +% \begin{syntax} +% |AP/N| = \meta{appearance name}\\ +% |AP/R| = \meta{appearance name}\\ +% |AP/D| = \meta{appearance name} +% \end{syntax} +% This keys set the normal, rollover and down appearance. Alias names are +% |appearance|, |rollover-appearance| and |down-appearance|. +% The value is by default a simple name of an appearance/form Xobject but +% modules like \pkg{l3pdffield-checkbox} change this to allow to add appearances for +% various states. +% \end{function} % -% \item[DV] optional, the default value after a reset. Should like |V| be either -% |/Yes| or |/Off|. +% \begin{function}{AS} +% \begin{syntax} +% |AS| = \meta{appearance state name} +% \end{syntax} +% This key sets the default appearance state. +% The value is a name without the starting slash +% (it is passed through |\pdf_name_from_unicode_e:n|), +% for checkbox for example |Yes|. If used it should typically have the same value +% as the V and DV key of the field. +% \end{function} % -% \item[AA] An action dictionary. For this we need a special command to setup such -% dictionaries, so that they then can be used in various places. +%\begin{function}{setannotflags,setF,unsetannotflags,unsetF} +% \begin{syntax} +% |setannotflags| = \meta{comma list of flags}\\ +% |setF| = \meta{comma list of flags}\\ +% |unsetannotflags| = |all| \verb"|" \meta{comma list of flags}\\ +% |unsetF| = |all| \verb"|" \meta{comma list of flags} +% \end{syntax} +% These keys allow to set or unset the annot flags. They expect a comma lists of +% flag names. Allowed names |Invisible|, |Hidden|, +% |Print|, |NoZoom|,|NoRotate|, |NoView|, |ReadOnly|, |Locked|, |ToggleNoView|, +% |LockedContents|, or the lowercase variants or numbers. +% \end{function} % -% \end{description} +% \begin{function}{AA/*} +% \begin{syntax} +% |AA/*| = \meta{string (ECMAScript)} +% \end{syntax} +% * should be one of |F|, |Bl|, |D|, |U|, |E|, |X|, |PO|, |PC|, |PV|, |PI|. +% Alias names for the first six keys are +% |onfocus|, |onblur|, |onmousedown|, |onmouseup|, |onenter|, |onexit|. +% These keys adds then the respective key to the |/AA| dictionary +% of the field annotation object. +% Their value should be javascript code. The |/AA| dictionary +% is suppressed if a pdf/A standard is set. +% +% For example +% \begin{verbatim} +% onenter={app.alert('Hello');} +% \end{verbatim} +% \end{function} % -% \subsubsection{The widget annotation dictionary} +% The following keys add values to the \emph{dynamic appearance dictionary} +% |MK| directory. This is only relevant for +% annotations with dynamic content, like e.g. textfields. +% The settings can also affect checkboxes and radio buttons if the (deprecated) +% |NeedAppearances| is set to true. +% +% The |MK| dictionary can also be added by using |\pdfannot_dict_put:nnn{Widget}{MK}{...}| +% but the two methods should not be mixed. +% +% \begin{function}{MK/R,rotate} +% \begin{syntax} +% |MK/R| = |0| \verb"|" |90| \verb"|" |180| \verb"|" |270|\\ +% |rotate| = |0| \verb"|" |90| \verb"|" |180| \verb"|" |270| +% \end{syntax} +% These rotates the content of the annotation. +% \end{function} % -% \begin{description} -% \item[Type] Value: |/Annot|, set automatically -% \item[Subtype] Value: |/Widget| this is added automatically. -% We use an internal dictionary which is locally copied over the one from l3pdfannot. -% It can be filled with keyval options. -% \item[Parent] The reference to the field, automatically added. -% \item[Rect] the size, calculated from the box size -% \item[Contents] a text string, not really needed but an optional key should allow to -% set it, -% \item[AP] the appearance dictionary. It should look like this -% |/AP <</N <</Yes 17 0 R/Off 15 0 R>>>>|. I need to test if it makes sense here to -% have a |/R| and |/D| entry too. The objects refer to suitable xforms. -% \item[AS] should be either |/Yes| or |/Off|, and sensibly by default be -% the same as the V entry in the field dictionary. If they differ the AS entry wins. +% \begin{function}{MK/BC,bordercolor} +% \begin{syntax} +% |MK/BC| = \meta{color expression} \verb"|" [\meta{model}]\Arg{values}\\ +% |bordercolor| = \meta{color expression} \verb"|" [\meta{model}]\Arg{values} +% \end{syntax} +% These colors the border. Internally currently RGB is used. +% The colors used in +% \meta{color expression} must be known to the \pkg{l3color} commands. +% \end{function} % -% \item[A] Action, this must be checked. -% \item[AA] additional actions. This must be checked too. +% \begin{function}{MK/BG,backgroundcolor} +% \begin{syntax} +% |MK/BG| = \meta{color expression} \verb"|" [\meta{model}]\Arg{values}\\ +% |backgroundcolor| = \meta{color expression} \verb"|" [\meta{model}]\Arg{values} +% \end{syntax} +% These colors the background. Internally currently RGB is used. +% The colors used in +% \meta{color expression} must be known to the \pkg{l3color} commands. +% \end{function} % -% \item[Border, C, OC, AF, BM, Lang, P, NM, M, F, BS, H]: These are not specifically -% needed for checkbox. An interface to add something to the used annot dictionary -% is needed (or already there), but probably no special key-val support for now. +% \begin{function}{MK/CA,caption} +% \begin{syntax} +% |MK/CA| = \meta{string}\\ +% |caption| = \meta{string} +% \end{syntax} +% This sets a text for the caption. \meta{string} is passed through \cs{pdf_string_from_unicode:nnN} +% and parentheses are added automatically. The font used seems to depend on +% the whims of the PDF reader: At least for checkboxes adobe reader quite insists to +% always use a symbol font and not a text font. It also shows always +% only one symbol, regardless how much one put in the string. +% hyperref uses the key names |checkboxsymbol| and +% |radiosymbol| for this setting. +% \end{function} % -% \item[MK] this is what hyperref uses to set the appearance, but I -% explicitly leave it out and use |AP|. +% The remaining key are useful for buttons only, currently no special syntax support +% is implemented. They will be handled when the code for push buttons is developed and +% tested. +% \begin{function}{MK/*} +% \begin{syntax} +% |MK/*| = \meta{various} +% \end{syntax} +% These keys adds the various entries in the \emph{dynamic appearance dictionary}. +% * should be one of |RC|, |AC|, |I|, |RI|, |IX|, |IF|, |TP|. +% The |MK| dictionary can also be added by using |\pdfannot_dict_put:nnn{Widget}{MK}{...}| +% but the two methods should not be mixed. +% \end{function} % -% \item[Q] (alignment), used by hyperref but not relevant as we don't have variable -% text here. -% \end{description} % \end{documentation} % % \begin{implementation} -% \section{\pkg{l3pdffield-checkbox} Implementation} +% \section{\pkg{l3pdffield} Implementation} % \begin{macrocode} %<*package> %<@@=pdffield> \NeedsTeXFormat{LaTeX2e} -\ProvidesExplPackage{l3pdffield-testphase}{2021-03-17}{0.95c}% - {form field checkboxes} +\ProvidesExplPackage{l3pdffield-testphase}{2021-05-14}{0.95d}% + {form fields} % \end{macrocode} % \subsection{hyperref specific command} % hyperref sets NeedAppearances by default. As this is deprecated we disable this. % \begin{macrocode} \csname HyField@NeedAppearancesfalse\endcsname % suppress NeedAppearances -% values from hyperref: -%\def\DefaultOptionsofCheckBox{print} -%\def\DefaultHeightofCheckBox{\normalbaselineskip} -%\def\DefaultWidthofCheckBox{\normalbaselineskip} % \end{macrocode} +% % \subsection{local variables} +% % \begin{macrocode} -\str_new:N \l_@@_field_name_str \str_new:N \l_@@_tmpa_str -\str_new:N \l_@@_name_tmpa_str -\tl_new:N \l_@@_keys_tmpa_tl +\tl_new:N \l_@@_tmpa_tl +\tl_new:N \l_@@_tmpa_keys_tl +\cs_new_protected:Npn \@@_tmpa:n #1 {} +\cs_new_protected:Npn \@@_tmpa:nn #1 #2 {} +\tl_new:N \l_@@_currentparent_tl +\tl_new:N \l_@@_fieldID_tl % \end{macrocode} % % \subsection{messages} @@ -383,15 +780,40 @@ } \msg_new:nnn {pdffield}{appearance-missing} { - The~appearance~`#1`~is~missing~for~the~#2~appearance. + The~appearance~definition~`#1`~is~missing~for~the~#2~appearance. + } +\msg_new:nnn {pdffield}{not-implemented} + { + Support~for~'/#1'~is~not~implemented\\ + The~key~is~ignored. + } +\msg_new:nnn {pdffield}{key-disabled} + { + key~`#2`~is~disabled~and~ignored~in~the~`#1`~command.\\ + Use~key~`#3`~instead. } -\msg_new:nnn {pdffield}{field-keys-ignored} +\msg_new:nnn {pdffield}{parent-field-missing} { - The~field~`#1`~is~already~initialized\\ - The~field~keys~`#2`~are~ignored. + The~parent~field~'#1'~doesn't~exist\\ + Create~it~with~\tl_to_str:n{\pdffield_field:nn} } % \end{macrocode} +% An auxiliary command to disable some keys +% \begin{macro}{\@@_key_disable:nnn} +% \begin{macrocode} +\cs_new_protected:Npn \@@_key_disable:nnn #1#2#3 + { + \keys_define:nn {pdffield} + { + #2 .code:n = + { + \msg_warning:nnnnn {pdffield}{key-disabled}{#1}{#2}{#3} + } + } + } +% \end{macrocode} +% \end{macro} % \subsection{bitsets} % A bitset for the field flag Ff % and an internal copy of the annot bitset. @@ -417,7 +839,27 @@ Comb = 25,%Tx, requires MaxLen in dict RadiosInUnison = 26,%Btn Radio RichText = 26,%Tx - CommitOnSelChange = 27 + CommitOnSelChange = 27, + readonly = 1, + required = 2, + noexport = 3, + multiline = 13,%Tx + password = 14, + notoggletooff = 15,%Btn, radio button + radio = 16,%Btn: Radio: 15=1, 16=0 + pushbutton = 17,%Btn: Checkbox: 15=0, 16=0 + %Btn: Pushbutton: 16=1 + combo = 18,%Ch: Combo=1 List=0 + edit = 19,%Ch, Combo=1 -> + edit field + sort = 20,%Ch, not relevant for view... + fileselect = 21,%Tx + multiselect = 22,%Ch + donotspellcheck = 23,%Tx, Ch (if Combo + Edit set) + donotscroll = 24,%Tx + comb = 25,%Tx, requires MaxLen in dict + radiosinunison = 26,%Btn Radio + richtext = 26,%Tx + commitonselchange = 27 } \bitset_new:Nn \l_@@_F_bitset @@ -431,102 +873,107 @@ ReadOnly = 7, Locked = 8, ToggleNoView = 9, - LockedContents = 10 + LockedContents = 10, + invisible = 1, + hidden = 2, + print = 3, + nozoom = 4, + norotate = 5, + noview = 6, + readonly = 7, + locked = 8, + togglenoview = 9, + lockedcontents = 10 } % \end{macrocode} % \subsection{The field dictionary} -% The field dictionary is the main object. It references the -% actual widget annotations as kids. It is created at the first -% checkbox with a specific name. +% The field dictionary is the main object. % To be able to set values from the outside it will use a % dictionary which can be filled by key-val. % \begin{macrocode} -\pdfdict_new:n {l_@@/checkbox/field} -\pdfdict_put:nnn {l_@@/checkbox/field}{FT}{/Btn} +\pdfdict_new:n {l_@@/field} +\pdfdict_new:n {l_@@/field/AA} +\bool_new:N \l_@@_root_field_bool % \end{macrocode} -% We need to check if the name contains a dot. But we will do this in an external command -% to avoid to have it twice. Here we assume that the name is already converted and safe. -% -% We also assume that values that can be changed by the user are set outside -% in the dictionary. -% If the field object already exists nothing is done. -% \begin{macro}{\@@_checkbox_field_add:n} +% \begin{macro}{\@@_field:n} % \begin{syntax} -% \cs{@@_checkbox_field_add:n}\Arg{name} +% \cs{@@_field:n}\Arg{field ID} % \end{syntax} -% \meta{name} should be a PDF text string without period. It identifies the -% field. % \begin{macrocode} -\cs_new_protected:Npn \@@_checkbox_field_new:n #1 +\cs_new_protected:Npn \@@_field:n #1 { - \group_begin: - \pdf_object_new:nn {@@_checkbox/field/#1} {dict} - \pdf_object_new:nn {@@_checkbox/field/#1/Kids} {array} - \seq_new:c {g_@@_checkbox/field/#1/Kids_seq} - \hook_gput_code:nnn {shipout/lastpage}{pdffield} %xetex needs this ... - { - \pdf_object_write:nx {@@_checkbox/field/#1/Kids} - { - \seq_use:cn{g_@@_checkbox/field/#1/Kids_seq}{~} - } - } - \pdfdict_put:nnn {l_@@/checkbox/field}{T}{(#1)} - % V,DV are names describing the appearance. With checkboxes - % the values /Yes and /Off are used. - % this values are taken from the outside - \pdfdict_put:nnx {l_@@/checkbox/field} - {Kids} - { - \pdf_object_ref:n {@@_checkbox/field/#1/Kids} - } - \bitset_set_false:Nn \l_@@_Ff_bitset {Radio} - \bitset_set_false:Nn \l_@@_Ff_bitset {Pushbutton} - \pdfdict_put:nnx {l_@@/checkbox/field} - {Ff} - {\bitset_to_arabic:N \l_@@_Ff_bitset } - \pdfdict_if_empty:nF{l_@@/checkbox/field/AA} - { - \pdfmeta_standard_verify:nT - {annot_widget_no_AA} - { - \pdfdict_put:nnx - {l_@@/checkbox/field} - {AA} - {<<\pdfdict_use:n {l_@@/checkbox/field/AA}>>} - } - } - \pdf_object_write:nx {@@_checkbox/field/#1} { \pdfdict_use:n {l_@@/checkbox/field} } - \pdfmanagement_add:nnx - { Catalog / AcroForm } - { Fields } - {\pdf_object_ref:n {@@_checkbox/field/#1} } - \group_end: + \pdf_object_new:nn {@@/field/#1} {dict} + \pdf_object_new:nn {@@/field/Kids/#1} {array} + \tl_if_empty:NTF \l_@@_currentparent_tl + { + \pdfmanagement_add:nnx + { Catalog / AcroForm } + { Fields } + {\pdf_object_ref:n {@@/field/#1} } + } + { + \exp_args:Ne + \pdf_object_if_exist:nTF {@@/field/\l_@@_currentparent_tl} + { + \pdfdict_put:nnx { l_@@/field }{Parent} + {\exp_args:Ne \pdf_object_ref:n{@@/field/\l_@@_currentparent_tl}} + \seq_gput_right:cx {g_@@_field/Kids/\l_@@_currentparent_tl _seq} + { \exp_args:Ne \pdf_object_ref:n{@@/field/#1}} + } + { + \msg_error:nnx {pdffield}{parent-field-missing}{\l_@@_currentparent_tl} + } + } + \seq_new:c {g_@@_field/Kids/#1_seq} + \pdfdict_put:nnx {l_@@/field} + {Kids} + { + \pdf_object_ref:n {@@/field/Kids/#1} + } + \pdfdict_put:nnx {l_@@/field} + {Ff} + {\bitset_to_arabic:N \l_@@_Ff_bitset } + \pdfdict_if_empty:nF{l_@@/field/AA} + { + \pdfmeta_standard_verify:nT + {annot_widget_no_AA} + { + \pdf_object_unnamed_write:nx {dict}{\pdfdict_use:n {l_@@/field/AA}} + \pdfdict_put:nnx + {l_@@/field} + {AA} + {\pdf_object_ref_last:} + } + } + \hook_gput_code:nnn {shipout/lastpage}{pdffield} %xetex needs this ... + { + \pdf_object_write:nx {@@/field/Kids/#1} + { + \seq_use:cn{g_@@_field/Kids/#1_seq}{~} + } + } + \pdf_object_write:nx {@@/field/#1} { \pdfdict_use:n {l_@@/field} } + } +\cs_new_protected:Npn \pdffield_field:nn #1 #2 + { + \group_begin: + \keys_set:nn { pdffield } {#1} + \@@_field:n {#2} + \group_end: } - % \end{macrocode} % \end{macro} +% % \subsection{The annot dictionary} % We assume that the annotation should really occupy space on the page and % leave vertical mode. -% We also assume that keys like AP, AS are added before through keys to -% the dictionary. -% We use a local dictionary which is copied into |l__pdfannot/widget| in the code. -% \begin{macrocode} -\pdfdict_new:n {l_@@/checkbox/annot} -\pdfdict_put:nnn {l_@@/checkbox/annot}{Subtype}{/Widget} -% \end{macrocode} % -% \begin{macro}{\@@_checkbox_annot_add:nnnn} +% \begin{macro}{\@@_annot:} +% The command doesn't add grouping, so should only be used inside a group. +% % \begin{macrocode} -\cs_new_protected:Npn \@@_checkbox_annot_add:nnnn #1 #2 #3 #4 %name, wd, ht, dp, +\cs_new_protected:Npn \@@_annot: { - \group_begin: -% \end{macrocode} -% Copy the internal dictionary to the pdfannot dictionary. This -% perhaps need a function in l3pdfannot, -% as it actually uses an internal name of another module. -% \begin{macrocode} - \pdfdict_put:nnx {l_@@/checkbox/annot}{AP}{<<\pdfdict_use:n{l_@@/checkbox/annot/AP}>>} \pdfmeta_standard_verify:nF {annot_flags} { @@ -535,428 +982,656 @@ \bitset_set_false:Nn \l_@@_F_bitset {Invisible} \bitset_set_false:Nn \l_@@_F_bitset {NoView} } - \pdfdict_if_empty:nF{l_@@/checkbox/annot/AA} + \pdfannot_dict_put:nnx {widget}{F}{ \bitset_to_arabic:N \l_@@_F_bitset } + \tl_if_empty:NF \l_@@_currentparent_tl { - \pdfmeta_standard_verify:nT - {annot_widget_no_AA} - { - \pdfdict_put:nnx - {l_@@/checkbox/annot} - {AA} - {<<\pdfdict_use:n {l_@@/checkbox/annot/AA}>>} - } - } - \pdfdict_put:nnx {l_@@/checkbox/annot}{F}{ \bitset_to_arabic:N \l_@@_F_bitset } - \pdfdict_set_eq:nn {l__pdfannot/widget}{l_@@/checkbox/annot} - \pdfannot_dict_put:nnx {widget}{Parent}{\pdf_object_ref:n{@@_checkbox/field/#1}} + \exp_args:Ne + \pdf_object_if_exist:nTF { @@/field/\l_@@_currentparent_tl } + { + \pdfannot_dict_put:nnx {widget}{Parent} + { + \exp_args:Ne + \pdf_object_ref:n{@@/field/\l_@@_currentparent_tl} + } + } + { + \msg_error:nnx { pdffield }{parent-field-missing}{\l_@@_currentparent_tl} + } + } \mode_leave_vertical: \hbox_to_wd:nn - { #2 } + { \l_@@_annot_wd_dim } { - \rule [-#4]{0pt}{\dim_eval:n{#3+#4} } + \rule [-\l_@@_annot_dp_dim]{0pt}{\dim_eval:n{\l_@@_annot_ht_dim+\l_@@_annot_dp_dim} } \pdfannot_widget_box:nnn - { #2 } - { #3 } - { #4 } + { \l_@@_annot_wd_dim } + { \l_@@_annot_ht_dim } + { \l_@@_annot_dp_dim } \hfill } - \seq_gput_right:cx {g_@@_checkbox/field/#1/Kids_seq}{ \pdfannot_box_ref_last:} - \group_end: - } - -% \end{macrocode} -% \end{macro} -% \subsection{Appearances} -% We don't try to force a size or content here. -% The default appearances are a cross (\cs{texttimes}), -% Every appearance should have two versions and follow the naming -% checkbox/\meta{name}/Yes and checkbox/\meta{name}/Off. -% TODO check if one delay the creation to a sensible place -% (and don't forget that the appearance key sets an initial -% value) -% \begin{macro}{\pdffield_store_appearance:nn,\@@_store_default_appearances:} -% \begin{macrocode} -\cs_new_protected:Npn \pdffield_store_appearance:nn #1 #2 - { - \pdfxform_new:nnn {@@_#1}{}{#2} + \tl_if_empty:NF \l_@@_currentparent_tl + { + \seq_if_exist:cTF {g_@@_field/Kids/\l_@@_currentparent_tl _seq} + { + \seq_gput_right:cx + {g_@@_field/Kids/\l_@@_currentparent_tl _seq} + { \pdfannot_box_ref_last:} + } + { + \msg_error:nnx { pdffield}{parent-field-missing}{\l_@@_currentparent_tl} + } + } } - -\cs_new_protected:Nn \@@_store_default_appearances: - { - \pdffield_store_appearance:nn {checkbox/default/Yes} - { - \normalsize - \fboxsep 0pt - \framebox - [ \dim_eval:n { \box_ht:N\strutbox+\box_dp:N\strutbox } ] - { \texttimes \strut } - } - \pdffield_store_appearance:nn {checkbox/default/Off} - { - \normalsize - \fboxsep 0pt - \framebox - [ \dim_eval:n { \box_ht:N\strutbox+\box_dp:N\strutbox } ] - { \phantom{\texttimes} \strut } - } - } - -\@@_store_default_appearances: -% \end{macrocode} -% \end{macro} -% We define a dictionary for the AP content, so that we can add R and D too -% \begin{macrocode} -\pdfdict_new:n {l_@@/checkbox/annot/AP} -% \end{macrocode} -% -% \subsection{Assembling the checkbox} -% \begin{macro}{\@@_checkbox_add:n} -% \begin{macrocode} - -\cs_new_protected:Npn \@@_checkbox_add:n #1 +\cs_new_protected:Npn \pdffield_annot:n #1 { \group_begin: - \keys_set_filter:nnnN {pdffield / checkbox }{field}{#1}\l_@@_keys_tmpa_tl - \str_if_empty:NT \l_@@_field_name_str - { - \msg_error:nn {pdffield}{empty-name} - } - \exp_args:Nx - \pdf_object_if_exist:nTF {@@_checkbox/field/\l_@@_field_name_str} - { - \tl_if_empty:NF \l_@@_keys_tmpa_tl - { - \msg_warning:nnxx - {pdffield} - {field-keys-ignored} - {\l_@@_field_name_str} - {\l_@@_keys_tmpa_tl} - } - } - { - \keys_set:nV { pdffield/checkbox } \l_@@_keys_tmpa_tl - \exp_args:No - \@@_checkbox_field_new:n {\l_@@_field_name_str} - } - \exp_args:No - \@@_checkbox_annot_add:nnnn - {\l_@@_field_name_str} - {\l_@@_annot_wd_tl } - {\l_@@_annot_ht_tl } - {\l_@@_annot_dp_tl } + \keys_set:nn { pdffield } {#1} + \@@_annot: \group_end: } % \end{macrocode} % \end{macro} -% \subsection{Keys} -% The size of the checkbox % +% \subsection{auxiliary command for color keys} % \begin{macrocode} -\tl_new:N \l_@@_annot_ht_tl -\tl_new:N \l_@@_annot_wd_tl -\tl_new:N \l_@@_annot_dp_tl +\cs_new_protected:Npn \@@_color_set:nn #1 #2 + { + \tl_if_head_eq_charcode:nNTF {#2}[ %] + { + \@@_color_set_aux:nwn { #1 } #2 + } + { + \color_set:nn {#1} {#2} + } + } -\keys_define:nn { pdffield / checkbox } +\cs_new_protected:Npn \@@_color_set_aux:nwn #1 [#2] #3 { - ,width .tl_set:N = \l_@@_annot_wd_tl - ,height .tl_set:N = \l_@@_annot_ht_tl - ,depth .tl_set:N = \l_@@_annot_dp_tl - ,width .initial:n = \normalbaselineskip - ,height .initial:n = \normalbaselineskip - ,depth .initial:n = 0pt + \color_set:nnn {#1}{#2}{#3} } + % \end{macrocode} +% \subsection{Field keys} % The names. The main name should not be empty, it is added to the dictionary % when the field is created. A new name means a new field. % The other names can only be set when the field is created, % so we put them in the field group. % \begin{macrocode} -\keys_define:nn { pdffield / checkbox } +\cs_new_protected:Npn \@@_value_handler:nN #1#2 + { + \tl_set:Nn #2 {#1} + } +\keys_define:nn { pdffield } { - ,name .code:n = + ,parent .tl_set:N = \l_@@_currentparent_tl + ,parent .groups:n = {field,annot} + ,T .code:n = { - \pdf_string_from_unicode:nnN {utf8/string-raw}{#1}\l_@@_field_name_str - \str_if_in:NnT \l_@@_field_name_str {.} + \pdf_string_from_unicode:nnN {utf8/string-raw}{#1}\l_@@_tmpa_str + \str_if_in:NnT \l_@@_tmpa_str {.} { - \msg_error:nnx {pdffield}{no-period}{\l_@@_field_name_str} + \msg_error:nnx {pdffield}{no-period}{\l_@@_tmpa_str} } - \str_if_empty:NT\l_@@_field_name_str + \str_if_empty:NTF\l_@@_tmpa_str { - \msg_error:nn {pdffield}{empty-name} + \msg_warning:nn {pdffield}{empty-name} + \pdfdict_remove:nn { l_@@/field }{T} + } + { + \pdfdict_put:nnx { l_@@/field }{T}{(\l_@@_tmpa_str)} } } + ,T .value_required:n = true + ,T .groups:n = {field} + ,name .meta:n = {T={#1}} ,name .value_required:n = true - ,name .initial:n = checkbox - ,altname .code:n = + ,name .groups:n = {field} + ,TU .groups:n = {field} + ,TU .code:n = { - \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_name_tmpa_str - \pdfdict_put:nnx { l_@@/checkbox/field }{TU}{\l_@@_name_tmpa_str} + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{TU} + } + { + \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_tmpa_str + \pdfdict_put:nnx { l_@@/field }{TU}{\l_@@_tmpa_str} + } } + ,TU .groups:n = {field} + ,altname .meta:n = {TU={#1}} ,altname .groups:n = {field} - ,mappingname .code:n = + ,TM .code:n = { - \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_name_tmpa_str - \pdfdict_put:nnx { l_@@/checkbox/field }{TM}{\l_@@_name_tmpa_str} + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{TM} + } + { + \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_tmpa_str + \pdfdict_put:nnx { l_@@/field }{TM}{\l_@@_tmpa_str} + } } + ,TM .groups:n = {field} + ,mappingname .meta:n = {TM={#1}} ,mappingname .groups:n = {field} - } -% \end{macrocode} - -% A key to decide if the Box is initially checked or not -% \begin{macrocode} -\keys_define:nn { pdffield / checkbox } - { - ,checked .choice: - ,checked / false .code:n = + ,FT .choices:nn = + { Btn, Tx, Ch, Sig } + { + \pdfdict_put:nnn { l_@@/field }{FT}{ /#1 } + } + ,FT .groups:n = {field} + ,V .code:n = { - \pdfdict_put:nnn {l_@@/checkbox/field}{V}{/Off} - \pdfdict_put:nnn {l_@@/checkbox/annot}{AS}{/Off} - \pdfdict_put:nnn {l_@@/checkbox/field}{DV}{/Off} + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{V} + } + { + \@@_value_handler:nN{#1}\l_@@_tmpa_str + \pdfdict_put:nnx { l_@@/field }{V}{ \l_@@_tmpa_str } + } } - ,checked / true .code:n = + ,V .groups:n = {field} + ,DV .code:n = { - \pdfdict_put:nnn {l_@@/checkbox/field}{V}{/Yes} - \pdfdict_put:nnn {l_@@/checkbox/annot}{AS}{/Yes} - \pdfdict_put:nnn {l_@@/checkbox/field}{DV}{/Yes} + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{DV} + } + { + \@@_value_handler:nN{#1}\l_@@_tmpa_str + \pdfdict_put:nnx { l_@@/field }{DV}{ \l_@@_tmpa_str } + } } - ,checked .default:n = {true} - ,checked .initial:n = {false} - } + ,DV .groups:n = {field} + ,MaxLen .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{MaxLen} + } + { + \pdfdict_put:nnx { l_@@/field }{MaxLen}{ #1 } + } + } + ,MaxLen .groups:n = {field} + ,Lock .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{Lock} + } + { + \pdfdict_put:nnx { l_@@/field }{Lock}{ \pdf_object_ref:n{#1} } + } + } + ,Lock .groups:n = {field} + ,SV .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{SV} + } + { + \pdfdict_put:nnx { l_@@/field }{SV}{ \pdf_object_ref:n{#1} } + } + } + ,SV .groups:n = {field} + ,Opt .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{Opt} + } + { + \pdfdict_put:nnx { l_@@/field }{Opt}{ \pdf_object_ref:n{#1} } + } + } + ,Opt .groups:n = {field} + ,TI .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{TI} + } + { + \pdfdict_put:nnx { l_@@/field }{TI}{ #1 } + } + } + ,TI .groups:n = {field} + ,I .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{I} + } + { + \pdfdict_put:nnx { l_@@/field }{I}{ \pdf_object_ref:n{#1} } + } + } + ,I .groups:n = {field} + } % \end{macrocode} -% Flags. We don't add lots of individual keys but mapped the key names directly + +% Flags. We don't add lots of individual keys but map the key names directly % \begin{macrocode} -\keys_define:nn { pdffield / checkbox } +\keys_define:nn { pdffield } { - ,setfieldflags .code:n = + ,setFf .code:n = { \clist_map_inline:nn {#1} { \bitset_set_true:Nn \l_@@_Ff_bitset {##1} } } + ,setFf .groups:n = {field} + ,setfieldflags .meta:n = + {setFf={#1}} ,setfieldflags .groups:n = {field} - ,unsetfieldflags .code:n = + ,unsetFf .multichoice: + ,unsetFf / all .code:n = { \bitset_clear:N \l_@@_Ff_bitset} + ,unsetFf / unknown .code:n = { - \clist_map_inline:nn {#1} - { - \bitset_set_false:Nn \l_@@_Ff_bitset {##1} - } + \bitset_set_false:Nn \l_@@_Ff_bitset {#1} } + ,unsetFf .groups:n = {field} + ,unsetfieldflags .meta:n = {unsetFf={#1}} ,unsetfieldflags .groups:n = {field} - ,setannotflags .code:n = + } + +% \end{macrocode} +% +% Keys for the AA dictionary. They all trigger a javascript option. +% K=keystroke, F=format, V=validate, C=calculate +% \begin{macrocode} +\cs_set_protected:Npn \@@_tmpa:n #1 % + { + \keys_define:nn { pdffield } { - \clist_map_inline:nn {#1} + AA/#1 .code:n = { - \bitset_set_true:Nn \l_@@_F_bitset {##1} - } + \pdf_string_from_unicode:nnN {utf8/string-raw}{##1}\l_@@_tmpa_str + \str_if_empty:NTF \l_@@_tmpa_str + { + \pdfdict_remove:nn {l_@@/field/AA}{#1} + } + { + \pdfdict_put:nnx {l_@@/field/AA} + {#1} + {<</S/JavaScript/JS(\l_@@_tmpa_str)>>} + } + }, + AA/#1 .groups:n = {field} } - ,unsetannotflags .code:n = + } + +\clist_map_inline:nn {K,F,V,C}{\@@_tmpa:n{#1}} + +\cs_set_protected:Npn \@@_tmpa:nn #1 #2 + { + \keys_define:nn { pdffield } { - \clist_map_inline:nn {#1} - { - \bitset_set_false:Nn \l_@@_F_bitset {##1} - } + #1 .meta:nn = + { pdffield }{AA/#2={##1}}, + #1 .groups:n = {field} } } +\@@_tmpa:nn {keystroke}{K} +\@@_tmpa:nn {format} {F} +\@@_tmpa:nn {validate} {V} +\@@_tmpa:nn {calculate}{C} + + +% \end{macrocode} +% +% \begin{macrocode} +\keys_define:nn { pdffield } + { + DA .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfdict_remove:nn { l_@@/field }{DA} + } + { + \pdfdict_put:nnx { l_@@/field }{DA}{ (#1) } + } + } + ,DA .groups:n = {field} + ,Q .choices:nn = {left,center,right} + { + \pdfdict_put:nnx { l_@@/field }{Q}{ \int_eval:n{\l_keys_choice_int-1} } + } + ,Q / .code:n = { \pdfdict_remove:nn { l_@@/field }{Q} } + ,Q .groups:n = {field} + ,align .meta:n={Q=#1} + ,DS .code:n = + { + \msg_warning:nnn {pdffield}{not-implemented}{DS} + } + ,DS .groups:n = {field} + ,RV .code:n = + { + \msg_warning:nnn {pdffield}{not-implemented}{RV} + } + ,RV .groups:n = {field} + } +% \end{macrocode} +% +% \subsection{Annotation keys} +% The size of the field annotation +% +% \begin{macrocode} +\dim_new:N \l_@@_annot_ht_dim +\dim_new:N \l_@@_annot_wd_dim +\dim_new:N \l_@@_annot_dp_dim -\keys_define:nn { pdffield / checkbox } +\keys_define:nn { pdffield } { - appearance .code:n = %value is a name of an appearance + ,width .dim_set:N = \l_@@_annot_wd_dim + ,height .dim_set:N = \l_@@_annot_ht_dim + ,depth .dim_set:N = \l_@@_annot_dp_dim + ,width .initial:n = 0pt + ,height .initial:n = 0pt + ,depth .initial:n = 0pt + } +% \end{macrocode} +% +% \begin{macrocode} +\keys_define:nn { pdffield } + { + %parent is defined in field + ,AS .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfannot_dict_remove:nn { widget }{AS} + } + { + \pdfannot_dict_put:nnx {widget}{AS}{\pdf_name_from_unicode_e:n{#1}} + } + } + ,AS .groups:n = annot + } +\cs_new_protected:Npn \@@_appearance_handler:nnn #1#2#3 + { + \pdfxform_if_exist:nTF { #1 } + { + \pdfannot_dict_put:nnx {widget/AP}{#2} + { + \pdfxform_ref:n {#1} + } + } + { + \msg_error:nnnn{pdffield}{appearance-missing}{#1}{#3} + } + } +\keys_define:nn { pdffield } + { + AP/N .code:n = { - \pdfxform_if_exist:nTF { @@_#1/Yes } + \tl_if_empty:nTF {#1} { - \pdfdict_put:nnn {l_@@/checkbox/annot/AP} - {N} - { - << - /Yes ~ \pdfxform_ref:n { @@_#1/Yes} - /Off ~ \pdfxform_ref:n { @@_#1/Off} - >> - } + \pdfannot_dict_remove:nn { widget/AP }{N} } { - \msg_error:nnnn{pdffield}{appearance-missing}{#1}{normal} + \@@_appearance_handler:nnn {#1}{N}{normal} } - }, - appearance .initial:n = checkbox/default, + } + ,AP/N .groups:n = annot + ,appearance .meta:n = {AP/N={#1}} } - -\keys_define:nn { pdffield / checkbox } +\keys_define:nn { pdffield } { - rollover-appearance .code:n = %value is a name of an appearance + AP/R .code:n = { + \tl_if_empty:nTF {#1} + { + \pdfannot_dict_remove:nn { widget/AP }{R} + } + { + \@@_appearance_handler:nnn {#1}{R}{rollover} + } + } + ,AP/R .groups:n = annot + ,rollover-appearance .meta:n = {AP/R={#1}} + } +\keys_define:nn { pdffield } + { + AP/D .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfannot_dict_remove:nn { widget/AP }{D} + } + { + \@@_appearance_handler:nnn {#1}{D}{rollover} + } + } + ,AP/D .groups:n = annot + ,down-appearance .meta:n = {AP/D={#1}} + } + +\keys_define:nn { pdffield } + { + MK/R .choices:nn = {0,90,180,270} + { + \pdfannot_dict_put:nnx {widget/MK}{R}{#1} + } + ,MK/R / .code:n = + { + \pdfannot_dict_remove:nn { widget/MK }{R} + } + ,MK/R .groups:n = annot + ,rotate .meta:n = {MK/R=#1} + } + +\keys_define:nn { pdffield } + { + MK/BC .code:n = + { \tl_if_empty:nTF {#1} - { - \pdfdict_remove:nn {l_@@/checkbox/annot/AP} {R} - } - { - \pdfxform_if_exist:nTF { @@_#1/Yes } - { - \pdfdict_put:nnn {l_@@/checkbox/annot/AP} - {R} - { - << - /Yes ~ \pdfxform_ref:n { @@_#1/Yes} - /Off ~ \pdfxform_ref:n { @@_#1/Off} - >> - } - } - { - \msg_warning:nnnn{pdffield}{appearance-missing}{#1}{rollover} - } + { + \pdfannot_dict_remove:nn { widget/MK }{BC} + } + { + \@@_color_set:nn {@@/tmp}{#1} + \color_export:nnN{@@/tmp}{space-sep-rgb}\l_@@_tmpa_tl + \pdfannot_dict_put:nnx {widget/MK}{BC}{[\l_@@_tmpa_tl]} + } + } + ,MK/BC .groups:n = annot + ,bordercolor .meta:n = {MK/BC=#1} + } - } - }, +\keys_define:nn { pdffield } + { + MK/BG .code:n = + { + \tl_if_empty:nTF {#1} + { + \pdfannot_dict_remove:nn { widget/MK }{BG} + } + { + \@@_color_set:nn {@@/tmp}{#1} + \color_export:nnN{@@/tmp}{space-sep-rgb}\l_@@_tmpa_tl + \pdfannot_dict_put:nnx {widget/MK}{BG}{[\l_@@_tmpa_tl]} + } + } + ,MK/BG .groups:n = annot + ,bordercolor .meta:n = {MK/BG=#1} } -\keys_define:nn { pdffield / checkbox } + +\keys_define:nn { pdffield } { - down-appearance .code:n = %value is a name of an appearance - { + MK/CA .code:n = + { \tl_if_empty:nTF {#1} - { - \pdfdict_remove:nn {l_@@/checkbox/annot/AP} {D} - } - { - \pdfxform_if_exist:nTF { @@_#1/Yes } + { + \pdfannot_dict_remove:nn { widget/MK }{CA} + } + { + \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_tmpa_str + \pdfannot_dict_put:nnx {widget/MK}{CA}{\l_@@_tmpa_str} + } + } + ,MK/CA .groups:n = annot + ,caption .meta:n = {MK/CA=#1} + } + +\cs_set_protected:Npn \@@_tmpa:n #1 + { + \keys_define:nn { pdffield } + { + MK/#1 .code:n = + { + \tl_if_empty:nTF {##1} { - \pdfdict_put:nnn {l_@@/checkbox/annot/AP} - {D} - { - << - /Yes ~ \pdfxform_ref:n { @@_#1/Yes} - /Off ~ \pdfxform_ref:n { @@_#1/Off} - >> - } + \pdfannot_dict_remove:nn { widget/AP }{#1} } { - \msg_warning:nnnn{pdffield}{appearance-missing}{#1}{down} + \pdfannot_dict_put:nnx {widget/MK}{#1}{##1} } - } - }, + } + ,MK/#1 .groups:n = annot + } + } + +\clist_map_inline:nn {RC,AC,I,RI,IX,IF,TP} + { \@@_tmpa:n {#1} } +% \end{macrocode} +% Flags. +% \begin{macrocode} +\keys_define:nn { pdffield } + { + ,setF .code:n = + { + \clist_map_inline:nn {#1} + { + \bitset_set_true:Nn \l_@@_F_bitset {##1} + } + } + ,setF .groups:n = annot + ,setannotflags .meta:nn = + { pdffield }{setF={#1}} + ,setannotflags .groups:n = annot + ,unsetF .multichoice: + ,unsetF / all .code:n = { \bitset_clear:N \l_@@_F_bitset} + ,unsetF / unknown .code:n = + { + \bitset_set_false:Nn \l_@@_F_bitset {#1} + } + ,unsetF .groups:n = annot + ,unsetannotflags .meta:nn = + { pdffield }{unsetF= {#1} } + ,unsetannotflags .groups:n = annot } + % \end{macrocode} % -% Keys for the AA dictionary. They all trigger javascript option. -% \begin{macro}{\@@_define_AAaction_key:nnn} +% Keys for the AA dictionary. They all trigger a javascript option. +% Fo = onfocus, Bl = onblur, D = onmousedown, U = onmouseup, +% E = onenter, X = onexit, PO = pageopen, PC = pageclose, +% PV = pagevisible, PI = pageinvisible % \begin{macrocode} -\pdfdict_new:n {l_@@/checkbox/annot/AA} -\pdfdict_new:n {l_@@/checkbox/field/AA} - -\cs_new_protected:Npn \@@_define_AAaction_key:nnn #1 #2 #3 %#1 key, #2 pdf, #3 dict +\cs_set_protected:Npn \@@_tmpa:n #1 % { - \keys_define:nn { pdffield / checkbox } + \keys_define:nn { pdffield } { - #1 .code:n = + AA/#1 .code:n = { - \pdf_string_from_unicode:nnN {utf8/string}{##1}\l_@@_tmpa_str + \pdf_string_from_unicode:nnN {utf8/string-raw}{##1}\l_@@_tmpa_str \str_if_empty:NTF \l_@@_tmpa_str { - \pdfdict_remove:nn {l_@@/checkbox/#3/AA}{#2} + \pdfannot_dict_remove:nn {widget/AA}{#1} } { - \pdfdict_put:nnx {l_@@/checkbox/#3/AA} - {#2} - {<</S/JavaScript/JS\l_@@_tmpa_str>>} + \pdfannot_dict_put:nnx {widget/AA} + {#1} + {<</S/JavaScript/JS(\l_@@_tmpa_str)>>} } }, - #1 .groups:n = {#3} + ,AA/#1 .groups:n = annot + } + } + +\clist_map_inline:nn {Fo,Bl,D,U,E,X,PO,PC,PV,PI}{\@@_tmpa:n{#1}} + +\cs_set_protected:Npn \@@_tmpa:nn #1 #2 + { + \keys_define:nn { pdffield } + { + #1 .meta:nn = + { pdffield }{AA/#2={##1}}, + #1 .groups:n = {annot} } } -\@@_define_AAaction_key:nnn {keystroke}{K}{field} -\@@_define_AAaction_key:nnn {format} {F}{field} -\@@_define_AAaction_key:nnn {validate} {V}{field} -\@@_define_AAaction_key:nnn {calculate}{C}{field} -\@@_define_AAaction_key:nnn {onfocus} {Fo}{annot} -\@@_define_AAaction_key:nnn {onblur} {Bl}{annot} -\@@_define_AAaction_key:nnn {onmousedown}{D}{annot} -\@@_define_AAaction_key:nnn {onmouseup}{U}{annot} -\@@_define_AAaction_key:nnn {onenter} {E}{annot} -\@@_define_AAaction_key:nnn {onexit} {X}{annot} +\@@_tmpa:nn {onfocus} {Fo} +\@@_tmpa:nn {onblur} {Bl} +\@@_tmpa:nn {onmousedown}{D} +\@@_tmpa:nn {onmouseup}{U} +\@@_tmpa:nn {onenter} {E} +\@@_tmpa:nn {onexit} {X} +% \end{macrocode} +% \subsection{Appearances} +% \begin{macro}{\pdffield_appearance:nn} +% \begin{macrocode} +\cs_new_protected:Npn \pdffield_appearance:nn #1 #2 + { + \pdfxform_new:nnn {#1}{}{#2} + } + +\cs_set_eq:NN \pdffield_store_appearance:nn\pdffield_appearance:nn % \end{macrocode} % \end{macro} -% \subsection{user commands} -% \begin{macro}{\pdffield_checkbox:n,\pdffield_setup:nn} +% \subsection{Setup command} +% % \begin{macrocode} -\cs_set_eq:NN \pdffield_checkbox:n \@@_checkbox_add:n +\keys_define:nn { pdffield / setup } + { + ,create-style .code:n = { \@@_style_create:nn #1 } + ,preset-checkbox .code:n = + { + \keys_define:nn { pdffield } + { + @@/preset/checkbox .meta:n = {#1}, + } + } + ,preset-textfield .code:n = + { + \keys_define:nn { pdffield } + { + @@/preset/textfield .meta:n = {#1}, + } + } + } +\keys_set:nn{ pdffield / setup }{preset-checkbox={}} +\keys_set:nn{ pdffield / setup }{preset-textfield={}} -\cs_new_protected:Npn \pdffield_setup:nn #1 #2 - { - \keys_set:nn {pdffield / #1 } {#2} - } +\cs_new_protected:Npn \@@_style_create:nn #1#2 + { + \keys_define:nn { pdffield } + { + @@/style/#1 .meta:n = {#2}, + } + } + + +\cs_new_protected:Npn \pdffield_setup:n #1 + { + \keys_set:nn{ pdffield / setup }{#1} + } + +\keys_define:nn { pdffield } + { + style .code:n = {\keys_set:nn {pdffield}{@@/style/#1={#1}}} + } +% \end{macrocode} +% \begin{macrocode} %</package> % \end{macrocode} -% \end{macro} %\end{implementation} - -\endinput% -%%%% -% -%Field dict -%Ft : /Btn /Tx /Ch /Sig -%Parent : OR -%Kids: array, other fields or annot/widget -%T: partial fieldname (test string) -%TU: alternate description (test string) -%TM: mapping name -%Q integer (variable text field) -%Ff: flags ->pdffield/checkbox/field -%V: value % not pushbutton -%DV: default value % not pushbutton -%AA: Action dict ... -> see below -%Opt: array of strings, connected to kids -% or for choices, choices -%TI integer (lists) -%I array Ch (complicated ...) -% -%/DA ( 0 0 1 rg /Ti 12 Tf ) %text field -%/MaxLen %text field -% -%Lock dict (Sig) -%SV dict (Sig) -% -% -% -% -%Connected widget: -%/AS default appearance from AP ( here/Yes or /Off) -%% Appearance -%%checkbox -%/AP <</N <</Yes 2 0 R /Off 3 0 R>>>> -%/C / Border /BS -% -%/OC ? -%/Structparens? -%/F flags -% -% -%AA: Submit: -% /S /SubmitForm -% /F file /URI (/F ( ftp : / / www . beatles . com / Movies / AbbeyRoad . mov ) -% /Fields array -% -% /S /ImportData -% /F file -% -% /S /ResetData -% /Fields array -% -% /S /JavaScript -% /JS text string or stream -% %\pdf_flag_new:nn {annot/field/submit} %name is wrong ... -% { -% Include/Exclude = 0, -% IncludeNoValueFields = 1, -% ExportFormat = 2, -% GetMethod = 3, % if ExportFormat=0 -> =0 to -% SubmitCoordinates = 4, % if ExportFormat=0 -> =0 to -% XFDF = 5, -% IncludeAppendSaves = 6, -% IncludeAnnotations = 7, -% SubmitPDF = 8, -% CanonicalFormat = 9, -% ExclNonUserAnnots = 10, -% ExclFKey = 11, -% EmbedForm = 12 -% } -% source: %adapted from https://chat.stackexchange.com/transcript/message/54421537#54421537 +% +% \PrintIndex diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield.pdf Binary files differindex 0c96ffee00..903cd42c0a 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffile.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdffile.dtx index e8810f81ff..cf2176e439 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdffile.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffile.dtx @@ -53,7 +53,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -262,7 +262,8 @@ % \end{syntax} % This commands embeds the file \meta{source filename} in the PDF, % and creates a |/Filespec| dictionary object named \meta{object name}. -% The object name must be unique. +% The object name must be unique, it should start with the module name, so +% e.g. \texttt{module/name}. % The command uses the content of the local % dictionaries |l_pdffile|, |l_pdffile/Params| and |l_pdffile/Filespec| % to setup the dictionary entries of the stream object and the @@ -360,12 +361,12 @@ % \l_tmpa_str % \pdfdict_put:nnx {l_pdffile/Filespec} {Desc}{\l_tmpa_str} % %embeds testinput.txt and calls it grüße.txt -% \pdffile_embed_file:nnn {testinput.txt}{grüße.txt}{file:example1} +% \pdffile_embed_file:nnn {testinput.txt}{grüße.txt}{mymodule/example1} % %reference it in the panel % \pdfmanagement_add:nnx % {Catalog/Names} % {EmbeddedFiles} -% {\pdf_object_ref:n{file:example1}} +% {\pdf_object_ref:n{mymodule/example1}} % \group_end: % \end{verbatim} % \end{documentation} @@ -376,7 +377,7 @@ % % \begin{macrocode} %<*header> -\ProvidesExplPackage{l3pdffile}{2021-03-17}{0.95c} +\ProvidesExplPackage{l3pdffile}{2021-05-14}{0.95d} {embedding and referencing files in PDF---LaTeX PDF management testphase bundle} \RequirePackage{l3pdftools} %temporarly!! %</header> @@ -456,6 +457,7 @@ ,.tex = text/plain %or application/x-tex, not in iana.org list ,.txt = text/plain ,.sty = text/plain + ,.xml = text/xml } % \end{macrocode} % \begin{variable} @@ -618,7 +620,6 @@ \msg_error:nn {pdffile}{target-name-missing} } { - \pdf_object_new:nn { #1 } {dict} \group_begin: \@@_filename_convert_to_print:nN { #2 } \l_@@_tmpa_str \pdfdict_put:nnx {l_pdffile/Filespec}{F} { \l_@@_tmpa_str } @@ -638,7 +639,7 @@ %#1 {source filename} %#2 {target filename} -%#3 { filespec object name } (will internally get a prefix!) +%#3 { filespec object name } (will internally get a prefix! ??) \cs_new_protected:Npn \pdffile_embed_file:nnn #1 #2 #3 { % if #1 empty => only filespec % if #2 empty => = #1 @@ -681,6 +682,7 @@ } \tl_if_blank:nTF { #2 } { + \pdf_object_new:nn { #3 } {dict} \exp_args:Nnnx \@@_filespec_write:nnn %#1 dict, #2 target file name, #3 object ref @@ -689,6 +691,7 @@ {\l_@@_embed_ref_tl} } { + \pdf_object_new:nn { #3 } {dict} \exp_args:Nnnx \@@_filespec_write:nnn %#1 dict, #2 target file name, #3 object ref @@ -722,6 +725,7 @@ { #1 } \l_@@_automimetype_tl \tl_set:Nx \l_@@_embed_ref_tl { \pdf_object_ref_last: } + \pdf_object_new:nn { #3 } {dict} \exp_args:Nnxx \@@_filespec_write:nnn %#1 dict, #2 target file name, #3 object ref diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffile.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdffile.pdf Binary files differindex f93e47b28d..b9b9a92b26 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdffile.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffile.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmanagement.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmanagement.dtx index e22600ea5b..9383c03290 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmanagement.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmanagement.dtx @@ -61,7 +61,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -517,9 +517,9 @@ % The value is an object reference. It is sensible to declare the object % first. E.g. % \begin{verbatim} -% \pdf_object_new:nn {pkg@intent}{dict} -% \pdf_object_write:nn {pkg@intent}{...} -% \pdfmanagement_add:nnx {Catalog} {OutputIntents}{\pdf_object_ref:n {pkg@intent}} +% \pdf_object_new:nn {module/intent}{dict} +% \pdf_object_write:nn {module/intent}{...} +% \pdfmanagement_add:nnx {Catalog} {OutputIntents}{\pdf_object_ref:n {module/intent}} % \end{verbatim} % % or @@ -557,7 +557,7 @@ %<@@=pdfmanagement> %<*header> % -\ProvidesExplPackage{l3pdfmanagement}{2021-03-17}{0.95c} +\ProvidesExplPackage{l3pdfmanagement}{2021-05-14}{0.95d} {Management of core PDF dictionaries (LaTeX PDF management testphase bundle)} %</header> % \end{macrocode} @@ -1115,15 +1115,15 @@ \prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AA } } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/AA_obj } { dict } + \__pdf_backend_object_new:nn { @@/Catalog/AA } { dict } \__pdf_backend_object_write:nx - { g_@@_/Catalog/AA_obj } + { @@/Catalog/AA } { \pdfdict_use:n { g__pdf_Core/Catalog/AA } } \exp_args:Nnx \__pdf_backend_catalog_gput:nn {AA} { - \__pdf_backend_object_ref:n { g_@@_/Catalog/AA_obj } + \__pdf_backend_object_ref:n { @@/Catalog/AA } } } } @@ -1145,67 +1145,67 @@ { \seq_if_empty:cF { g_@@_/Catalog/AcroForm/Fields_seq } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/AcroForm/Fields_obj } { array } + \__pdf_backend_object_new:nn { @@/Catalog/AcroForm/Fields } { array } \__pdf_backend_object_write:nx - { g_@@_/Catalog/AcroForm/Fields_obj } + { @@/Catalog/AcroForm/Fields } { \seq_use:cn { g_@@_/Catalog/AcroForm/Fields_seq } {~} } \exp_args:Nnnx \prop_gput:cnn %we have to use \prop here to avoid the handler ... { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm } } { Fields } - { \__pdf_backend_object_ref:n { g_@@_/Catalog/AcroForm/Fields_obj } } + { \__pdf_backend_object_ref:n { @@/Catalog/AcroForm/Fields } } } \seq_if_empty:cF { g_@@_/Catalog/AcroForm/CO_seq } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/AcroForm/CO_obj } { array } + \__pdf_backend_object_new:nn { @@/Catalog/AcroForm/CO } { array } \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/AcroForm/CO_obj } + { @@/Catalog/AcroForm/CO } { \seq_use:cn { g_@@_/Catalog/AcroForm/CO_seq } {~} } \exp_args:Nnnx \prop_gput:cnn %we have to use \prop here to avoid the handler ... { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm } } { CO } - { \__pdf_backend_object_ref:n { g_@@_/Catalog/AcroForm/CO_obj } } + { \__pdf_backend_object_ref:n { @@/Catalog/AcroForm/CO } } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm/DR/Font}} { - \__pdf_backend_object_new:nn { g_@@_/Catalog/AcroForm/DR/Font_obj } {dict} + \__pdf_backend_object_new:nn { @@/Catalog/AcroForm/DR/Font } {dict} \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/AcroForm/DR/Font_obj } + { @@/Catalog/AcroForm/DR/Font } { \pdfdict_use:n { g__pdf_Core/Catalog/AcroForm/DR/Font } } \exp_args:Nnnx \prop_gput:cnn %we have to use \prop here to avoid the handler ... { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm/DR } } { Font } - { \__pdf_backend_object_ref:n { g_@@_/Catalog/AcroForm/DR/Font_obj } } + { \__pdf_backend_object_ref:n { @@/Catalog/AcroForm/DR/Font } } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm/DR}} { - \__pdf_backend_object_new:nn { g_@@_/Catalog/AcroForm/DR_obj } {dict} + \__pdf_backend_object_new:nn { @@/Catalog/AcroForm/DR } {dict} \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/AcroForm/DR_obj } + { @@/Catalog/AcroForm/DR } { \pdfdict_use:n { g__pdf_Core/Catalog/AcroForm/DR } } \exp_args:Nnnx \prop_gput:cnn %we have to use \prop here to avoid the handler ... { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm } } { DR } - { \__pdf_backend_object_ref:n { g_@@_/Catalog/AcroForm/DR_obj } } + { \__pdf_backend_object_ref:n { @@/Catalog/AcroForm/DR } } } \prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/AcroForm} } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/AcroForm_obj } {dict} + \__pdf_backend_object_new:nn { @@/Catalog/AcroForm } {dict} \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/AcroForm_obj } + { @@/Catalog/AcroForm } { \pdfdict_use:n { g__pdf_Core/Catalog/AcroForm } } \exp_args:Nnnx \@@_handler_gput:nnn { Catalog } { AcroForm } - { \__pdf_backend_object_ref:n { g_@@_/Catalog/AcroForm_obj } } + { \__pdf_backend_object_ref:n { @@/Catalog/AcroForm } } } } @@ -1221,16 +1221,16 @@ \seq_if_empty:cF { g_@@_/Catalog/AF_seq } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/AF_obj } { array } + \__pdf_backend_object_new:nn { @@/Catalog/AF } { array } \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/AF_obj } + { @@/Catalog/AF } { \seq_use:cn { g_@@_/Catalog/AF_seq } {~} } \exp_args:Nnx \__pdf_backend_catalog_gput:nn {AF} { - \__pdf_backend_object_ref:n {g_@@_/Catalog/AF_obj} + \__pdf_backend_object_ref:n {@@/Catalog/AF} } } } @@ -1245,16 +1245,16 @@ \prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/MarkInfo } } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/MarkInfo_obj } { dict } + \__pdf_backend_object_new:nn { @@/Catalog/MarkInfo } { dict } \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/MarkInfo_obj } + { @@/Catalog/MarkInfo } { \pdfdict_use:n { g__pdf_Core/Catalog/MarkInfo } } \exp_args:Nnx \__pdf_backend_catalog_gput:nn {MarkInfo} { - \__pdf_backend_object_ref:n {g_@@_/Catalog/MarkInfo_obj} + \__pdf_backend_object_ref:n {@@/Catalog/MarkInfo} } } } @@ -1286,10 +1286,10 @@ > { 0 } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/OCProperties_obj } { dict } + \__pdf_backend_object_new:nn { @@/Catalog/OCProperties } { dict } \seq_gpop_left:cN { g_@@_/Catalog/OCProperties/Configs_seq} \l_tmpa_tl \exp_args:Nnx - \__pdf_backend_object_write:nn {g_@@_/Catalog/OCProperties_obj} + \__pdf_backend_object_write:nn {@@/Catalog/OCProperties} { /OCGs~[ \seq_use:cn { g_@@_/Catalog/OCProperties/OCGs_seq } {~} ] /D~\l_tmpa_tl~ @@ -1302,7 +1302,7 @@ \exp_args:Nnx \__pdf_backend_catalog_gput:nn { OCProperties } - { \__pdf_backend_object_ref:n {g_@@_/Catalog/OCProperties_obj} } + { \__pdf_backend_object_ref:n {@@/Catalog/OCProperties} } } } % \end{macrocode} @@ -1317,16 +1317,16 @@ \seq_if_empty:cF { g_@@_/Catalog/OutputIntents_seq } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/OutputIntents_obj } { array } + \__pdf_backend_object_new:nn { @@/Catalog/OutputIntents } { array } \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/OutputIntents_obj } + { @@/Catalog/OutputIntents } { \seq_use:cn { g_@@_/Catalog/OutputIntents_seq } {~} } \exp_args:Nnx \__pdf_backend_catalog_gput:nn {OutputIntents} { - \__pdf_backend_object_ref:n {g_@@_/Catalog/OutputIntents_obj} + \__pdf_backend_object_ref:n {@@/Catalog/OutputIntents} } } } @@ -1342,16 +1342,16 @@ \seq_if_empty:cF { g_@@_/Catalog/Requirements_seq } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/Requirements_obj } { array } + \__pdf_backend_object_new:nn { @@/Catalog/Requirements } { array } \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/Requirements_obj } + { @@/Catalog/Requirements } { \seq_use:cn { g_@@_/Catalog/Requirements_seq } {~} } \exp_args:Nnx \__pdf_backend_catalog_gput:nn {Requirements} { - \__pdf_backend_object_ref:n { g_@@_/Catalog/Requirements_obj } + \__pdf_backend_object_ref:n { @@/Catalog/Requirements } } } } @@ -1367,16 +1367,16 @@ \prop_if_empty:cF { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog/ViewerPreferences } } { - \__pdf_backend_object_new:nn { g_@@_/Catalog/ViewerPreferences_obj } { dict } + \__pdf_backend_object_new:nn { @@/Catalog/ViewerPreferences } { dict } \exp_args:Nnx \__pdf_backend_object_write:nn - { g_@@_/Catalog/ViewerPreferences_obj } + { @@/Catalog/ViewerPreferences } { \pdfdict_use:n { g__pdf_Core/Catalog/ViewerPreferences } } \exp_args:Nnx \__pdf_backend_catalog_gput:nn {ViewerPreferences} { - \__pdf_backend_object_ref:n {g_@@_/Catalog/ViewerPreferences_obj} + \__pdf_backend_object_ref:n {@@/Catalog/ViewerPreferences} } } } diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmanagement.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmanagement.pdf Binary files differindex 92e9fe605e..b35c3a3a4d 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmanagement.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmanagement.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx index 2b48f0646c..44ea8a9191 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx @@ -53,7 +53,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -340,7 +340,7 @@ % \begin{macrocode} %<@@=pdfmeta> %<*header> -\ProvidesExplPackage{l3pdfmeta}{2021-03-17}{0.95c} +\ProvidesExplPackage{l3pdfmeta}{2021-05-14}{0.95d} {PDF-Standards---LaTeX PDF management testphase bundle} %</header> % \end{macrocode} diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.pdf Binary files differindex f41e8f553f..7b8fdcea93 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdftools.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdftools.dtx index 60d60d184e..76368fc475 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdftools.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdftools.dtx @@ -53,7 +53,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -198,9 +198,9 @@ % It should be on the same page as the bdc-command. % % \begin{verbatim} -% \pdf_object_new:nn {objA}{dict} -% \pdf_object_write:nn {objA}{/Type/Artifact} -% \pdf_bdc:nn {Span}{objA} +% \pdf_object_new:nn {module/objA}{dict} +% \pdf_object_write:nn {module/objA}{/Type/Artifact} +% \pdf_bdc:nn {Span}{module/objA} % text % \pdf_emc: % \end{verbatim} @@ -215,7 +215,7 @@ % % \begin{macrocode} %<*header> -\ProvidesExplPackage{l3pdftools}{2021-03-17}{0.95c} +\ProvidesExplPackage{l3pdftools}{2021-05-14}{0.95d} {candidate commands for l3pdf---LaTeX PDF management testphase bundle} %</header> % \end{macrocode} diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdftools.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdftools.pdf Binary files differindex ed1f4381e4..4df0731176 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdftools.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdftools.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.dtx index f0fcda4aab..25465bdcb0 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.dtx @@ -52,7 +52,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -133,7 +133,7 @@ % \begin{macrocode} %<@@=pdf> %<*header> -\ProvidesExplPackage{l3pdfxform}{2021-03-17}{0.95c} +\ProvidesExplPackage{l3pdfxform}{2021-05-14}{0.95d} {command to create xforms (beta)---LaTeX PDF management testphase bundle} %</header> % \end{macrocode} diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.pdf b/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.pdf Binary files differindex 8b0acbedcf..8ff3c6f2d5 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfxform.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/ltdocinit.dtx b/macros/latex/contrib/pdfmanagement-testphase/ltdocinit.dtx index fec2da64ba..4d6974eefe 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/ltdocinit.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/ltdocinit.dtx @@ -51,7 +51,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -164,7 +164,7 @@ % \begin{macrocode} %<@@=pdfmanagement> %<*header> -\ProvidesExplPackage{ltdocinit}{2021-03-17}{0.95c} +\ProvidesExplPackage{ltdocinit}{2021-05-14}{0.95d} {Initialize document metadata} %</header> % \end{macrocode} diff --git a/macros/latex/contrib/pdfmanagement-testphase/ltdocinit.pdf b/macros/latex/contrib/pdfmanagement-testphase/ltdocinit.pdf Binary files differindex 81e648525e..a7138a39fc 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/ltdocinit.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/ltdocinit.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/pdflscape-ltx.sty b/macros/latex/contrib/pdfmanagement-testphase/pdflscape-ltx.sty index d43c363fe5..43ac3a7ce9 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/pdflscape-ltx.sty +++ b/macros/latex/contrib/pdfmanagement-testphase/pdflscape-ltx.sty @@ -22,7 +22,7 @@ %% This work consists of the main source file pdflscape-ltx.sty %% \NeedsTeXFormat{LaTeX2e} -\ProvidesExplPackage{pdflscape-ltx}{2021-03-17}{0.95c} +\ProvidesExplPackage{pdflscape-ltx}{2021-05-14}{0.95d} {Display of landscape pages in PDF - adaption of pdflscape to the PDFmanagement bundle (testphase)} \RequirePackage{lscape} diff --git a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-firstaid.dtx b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-firstaid.dtx index 54fb0ffa10..647fd55f93 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-firstaid.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-firstaid.dtx @@ -51,7 +51,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -67,7 +67,7 @@ % |firstaidoff={name1,name2,...}|. % \begin{macrocode} %<*package> -\ProvidesExplPackage{pdfmanagement-firstaid}{2021-03-17}{0.95c} +\ProvidesExplPackage{pdfmanagement-firstaid}{2021-05-14}{0.95d} {LaTeX PDF management testphase bundle / firstaid-patches} %<@@=pdfmanagement> @@ -192,9 +192,9 @@ %objects are already created ... \def\pgf@sys@pdf@possible@resources { - /ColorSpace~\pdf_object_ref:n {Page/Resources/ColorSpace} - /Pattern ~\pdf_object_ref:n {Page/Resources/Pattern} - /ExtGState ~\pdf_object_ref:n {Page/Resources/ExtGState} + /ColorSpace~\pdf_object_ref:n {__pdf/Page/Resources/ColorSpace} + /Pattern ~\pdf_object_ref:n {__pdf/Page/Resources/Pattern} + /ExtGState ~\pdf_object_ref:n {__pdf/Page/Resources/ExtGState} } \let\pgf@sys@pdf@check@resources=\relax% %not sure if needed, but perhaps the lists are used somewhere else ... @@ -227,24 +227,22 @@ } \cs_generate_variant:Nn \tl_trim_spaces:n{V} -\cs_generate_variant:Nn \__pdf_backend_PageResources_gput:nnn {nex} +\cs_generate_variant:Nn \pdfmanagement_add:nnn {nex} \cs_new:Npn \@@_patch_pgfextgs:w #1/#2<<#3>>#4\q_stop { \tl_set:Nx\l_tmpa_tl{#2} - \__pdf_backend_PageResources_gput:nex - {ExtGState}{\tl_trim_spaces:V\l_tmpa_tl}{<<#3 #4>>} + \pdfmanagement_add:nex + {Page/Resources/ExtGState}{\tl_trim_spaces:V\l_tmpa_tl}{<<#3 #4>>} } \cs_new:Npn \@@_patch_pgfpatterns:w #1/#2\space#3\q_stop { - \exp_args:Nnxx - \__pdf_backend_PageResources_gput:nnn - {Pattern}{\tl_trim_spaces:n{#2}}{#3} + \pdfmanagement_add:nex + {Page/Resources/Pattern}{\tl_trim_spaces:n{#2}}{#3} } \cs_new:Npn \@@_patch_pgfcolorspaces:w #1/#2[#3]#4\q_stop { - \exp_args:Nne - \__pdf_backend_PageResources_gput:nnn - {ColorSpace}{\tl_trim_spaces:n{#2}}{[#3]} + \pdfmanagement_add:nex + {Page/Resources/ColorSpace}{\tl_trim_spaces:n{#2}}{[#3]} } % \end{macrocode} diff --git a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-firstaid.pdf b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-firstaid.pdf Binary files differindex d702eae143..41b232b735 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-firstaid.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-firstaid.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.dtx b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.dtx index 8cee17982e..82dc047ada 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.dtx @@ -51,7 +51,7 @@ % }^^A % } % -% \date{Version 0.95c, released 2021-03-17} +% \date{Version 0.95d, released 2021-05-14} % % \maketitle % \begin{documentation} @@ -384,7 +384,7 @@ % \begin{macrocode} %<@@=pdf> %<*package> -\ProvidesExplPackage{pdfmanagement-testphase}{2021-03-17}{0.95c} +\ProvidesExplPackage{pdfmanagement-testphase}{2021-05-14}{0.95d} {LaTeX PDF management testphase bundle} \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} \IfFormatAtLeastTF{2020-10-01}{}{ @@ -411,7 +411,7 @@ % to allow to set it in the document. % \begin{macrocode} %<*header> -\ProvidesExplFile{pdfmanagement-testphase.ltx}{2021-03-17}{0.95c} +\ProvidesExplFile{pdfmanagement-testphase.ltx}{2021-05-14}{0.95d} {PDF~management~code~(testphase)} %</header> %<*package> diff --git a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.ins b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.ins index 87ac62f1b0..97db2f066e 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.ins +++ b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.ins @@ -128,6 +128,8 @@ and all files in that bundle must be distributed together. \file{l3pdffield-testphase.sty} {% \from{l3pdffield.dtx}{package} + \from{l3pdffield-checkbox.dtx}{package} + \from{l3pdffield-textfield.dtx}{package} }% } diff --git a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.pdf b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.pdf Binary files differindex cc1239e23a..2d1700dd49 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.pdf +++ b/macros/latex/contrib/pdfmanagement-testphase/pdfmanagement-testphase.pdf diff --git a/macros/latex/contrib/pdfmanagement-testphase/transparent-ltx.sty b/macros/latex/contrib/pdfmanagement-testphase/transparent-ltx.sty index 8d5abb7e2a..4b4030c4b2 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/transparent-ltx.sty +++ b/macros/latex/contrib/pdfmanagement-testphase/transparent-ltx.sty @@ -3,7 +3,7 @@ %% a replacement for transparent sty from Heiko Oberdiek %% \NeedsTeXFormat{LaTeX2e}[2020/10/01] -\ProvidesExplPackage{transparent-ltx}{2021-03-17}{0.95c} +\ProvidesExplPackage{transparent-ltx}{2021-05-14}{0.95d} {Transparency with color stacks (replacement for transparent.sty from Heiko Oberdiek)}% \RequirePackage{l3opacity} diff --git a/macros/latex/contrib/pdfmanagement-testphase/xcolor-patches-tmp-ltx.sty b/macros/latex/contrib/pdfmanagement-testphase/xcolor-patches-tmp-ltx.sty index aec0fbb632..76aee08fef 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/xcolor-patches-tmp-ltx.sty +++ b/macros/latex/contrib/pdfmanagement-testphase/xcolor-patches-tmp-ltx.sty @@ -1,26 +1,44 @@ %% LaTeX2e file `xcolor-patches.sty' %% -\ProvidesPackage{xcolor-patches-tmp-ltx}[2021-03-17 v0.95c patch xcolor for l3color] +\ProvidesPackage{xcolor-patches-tmp-ltx}[2021-05-14 v0.95d patch xcolor for l3color] \@ifundefined{color_set:nn}{\RequirePackage{l3color}}{} \ExplSyntaxOn -\cs_gset_protected:Npn \@expl@xcolor@set@@nnn #1 #2 #3 +% #1 is the color name +% #2: model or models +% #3: value: either numbers or a color name +% #4 is the type: named or ps +\cs_gset_protected:Npn \@expl@xcolor@set@@nnnn #1 #2 #3 #4 { - \cs_if_exist:cTF { __color_parse_model_ #2 :w } - { - \color_set:nnn {#1}{#2}{#3} - } - { - \tl_if_eq:nnTF{#2}{named} - { - \color_set:nn{#1}{#3} - } - { - %this is for multi models, it will break if there is model - %l3 doesn't know, but the case is rare, so accept it for now. - \color_set:nnn{#1}{#2}{#3} - } - } + \str_case:nnF {#4} + { + % we ignore the ps type for now. + {ps}{} + {named} + { + \cs_if_exist:cT { __color_parse_model_ #2 :w } + { + \color_set:nnn {#1}{#2}{#3} + } + } + } + { + \cs_if_exist:cTF { __color_parse_model_ #2 :w } + { + \color_set:nnn {#1}{#2}{#3} + } + { + \tl_if_eq:nnTF{#2}{named}%this the model not the type! + { + \color_set:nn{#1}{#3} + } + { + %this is for multi models, it will break if there is model + %l3 doesn't know, but the case is rare, so accept it for now. + \color_set:nnn{#1}{#2}{#3} + } + } + } } \cs_generate_variant:Nn \color_set:nn {ne} \cs_new_protected:Npn \@expl@xcolor@set@@ne #1 #2 @@ -58,7 +76,7 @@ %\pretocmd{\XC@definec@lor}{\@expl@color@set@@nnn{#2}{#4}{#5}}{}{\fail} \def\XC@definec@lor[#1]#2[#3]#4#5% - {\@expl@xcolor@set@@nnn{#2}{#4}{#5}% + {\@expl@xcolor@set@@nnnn{#2}{#4}{#5}{#1}% \begingroup \XC@sdef\@@cls{#1}\XC@edef\@@nam{#2}\edef\colornameprefix{#3}% \XC@logdef\@@nam diff --git a/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf b/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf Binary files differindex 842e63c3ca..ee0a252f02 100644 --- a/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf +++ b/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf diff --git a/macros/latex/contrib/profcollege/latex/ProfCollege.sty b/macros/latex/contrib/profcollege/latex/ProfCollege.sty index eb53ab6098..563ce3af32 100644 --- a/macros/latex/contrib/profcollege/latex/ProfCollege.sty +++ b/macros/latex/contrib/profcollege/latex/ProfCollege.sty @@ -3,7 +3,7 @@ % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{ProfCollege}[2021/04/09 v0.99-a Aide pour l'utilisation de LaTeX au collège] +\ProvidesPackage{ProfCollege}[2021/05/15 v0.99-b Aide pour l'utilisation de LaTeX au collège] \RequirePackage{verbatim} @@ -740,7 +740,7 @@ \end{mplibcode} \else \begin{mpost}[mpsettings={input PfCCalculatrice;}] - LCD(#1)(#2); + LCD(#1)(#2)(#3); \end{mpost} \fi } @@ -1399,7 +1399,7 @@ %%% \setKVdefault[ClesFraction]{Rayon=2cm,Disque,Regulier=false,Segment=false,Rectangle=false,Longueur=5cm,Largeur=2cm,Cotes=5,Triangle=false,Parts=3,Couleur=green,Reponse=false,Multiple=1,Hachures=false,Epaisseur=1} -\def\MPFractionTriangle#1#2#3#4#5{ +\def\MPFractionTriangle#1#2#3#4#5{% % #1 longueur du c\^ot\'e % #2 partage sur le c\^ot\'e % #3 num @@ -1437,20 +1437,32 @@ for k=nbparts downto 1: Ligne(k); endfor; + + m:=#3 div #4; - for k=1 upto #3: - fill M[k] withcolor #5; + drawoptions(shifted(m*(#1+1cm,0))); + for l=1 upto (#3 mod #4): + fill M[l] withcolor #5; + for k=1 upto nbparts: + trace segment((k/nbparts)[A,B],(k/nbparts)[A,C]); + trace segment((k/nbparts)[B,A],(k/nbparts)[B,C]); + trace segment((k/nbparts)[C,A],(k/nbparts)[C,B]); + endfor; endfor; + for l=0 upto (m-1): + drawoptions(shifted(l*(#1+1cm,0))); + remplis polygone(A,B,C) withcolor #5; for k=1 upto nbparts: trace segment((k/nbparts)[A,B],(k/nbparts)[A,C]); trace segment((k/nbparts)[B,A],(k/nbparts)[B,C]); trace segment((k/nbparts)[C,A],(k/nbparts)[C,B]); endfor; + endfor; \end{mplibcode} \else \begin{mpost} - nbtriangle=0; + nbtriangle=0; vardef Ligne(expr longueur)= for k=0 upto 2*(longueur-1): @@ -1479,16 +1491,28 @@ for k=nbparts downto 1: Ligne(k); endfor; + + m:=#3 div #4; - for k=1 upto #3: - fill M[k] withcolor #5; + drawoptions(shifted(m*(#1+1cm,0))); + for l=1 upto (#3 mod #4): + fill M[l] withcolor #5; + for k=1 upto nbparts: + trace segment((k/nbparts)[A,B],(k/nbparts)[A,C]); + trace segment((k/nbparts)[B,A],(k/nbparts)[B,C]); + trace segment((k/nbparts)[C,A],(k/nbparts)[C,B]); + endfor; endfor; + for l=0 upto (m-1): + drawoptions(shifted(l*(#1+1cm,0))); + remplis polygone(A,B,C) withcolor #5; for k=1 upto nbparts: trace segment((k/nbparts)[A,B],(k/nbparts)[A,C]); trace segment((k/nbparts)[B,A],(k/nbparts)[B,C]); trace segment((k/nbparts)[C,A],(k/nbparts)[C,B]); endfor; + endfor; \end{mpost} \fi } @@ -1503,7 +1527,7 @@ \ifluatex \mplibforcehmode \begin{mplibcode} - nbtriangle=0; + nbtriangle=0; vardef Ligne(expr longueur)= for k=0 upto 2*(longueur-1): @@ -1532,19 +1556,30 @@ for k=nbparts downto 1: Ligne(k); endfor; - - diversite=floor(uniformdeviate(#2**2-#3-1)); - for k=(1+diversite) upto (#3+diversite): + m:=#3 div #4; + + for l=1 upto (#3 mod #4): drawoptions(withpen pencircle scaled #6); - trace hachurage(M[k],90,0.2,0) withcolor #5; - endfor; + trace hachurage(M[l] shifted(m*(#1+1cm,0)),90,0.2,0) withcolor #5;%M[l] withcolor #5; + for k=1 upto nbparts: drawoptions(withpen pencircle scaled #6); + trace segment((k/nbparts)[A,B],(k/nbparts)[A,C]) shifted(m*(#1+1cm,0)); + trace segment((k/nbparts)[B,A],(k/nbparts)[B,C]) shifted(m*(#1+1cm,0)); + trace segment((k/nbparts)[C,A],(k/nbparts)[C,B]) shifted(m*(#1+1cm,0)); + endfor; + endfor; + + for l=0 upto (m-1): + drawoptions(shifted(l*(#1+1cm,0)) withpen pencircle scaled #6); + trace hachurage(polygone(A,B,C),90,0.2,0) withcolor #5;%polygone(A,B,C) withcolor #5; + drawoptions(shifted(l*(#1+1cm,0)) withpen pencircle scaled #6); for k=1 upto nbparts: trace segment((k/nbparts)[A,B],(k/nbparts)[A,C]); trace segment((k/nbparts)[B,A],(k/nbparts)[B,C]); trace segment((k/nbparts)[C,A],(k/nbparts)[C,B]); endfor; + endfor; \end{mplibcode} \else \begin{mpost} @@ -1594,7 +1629,6 @@ \end{mpost} \fi } - \def\MPFractionRegulier#1#2#3#4#5{% % #1 rayon, #2 nb c\^ot\'es, #3 num, #4 deno, #5 couleur @@ -1612,19 +1646,40 @@ for k=0 upto #4-1: B[k]=point(k*(#2/#4)) of cd; endfor; - remplis O--arccercle(B[0],B[#3],O)--cycle withcolor #5; - %fi; + picture fondcolore; + fondcolore=image( + remplis O--arccercle(B[0],B[#3 mod #4],O)--cycle withcolor #5; clip currentpicture to cd; - draw polygone(A0 for k=1 upto #2:,A[k] endfor); - if #4>1: for k=0 upto #4-1: draw segment(O,B[k]) cutafter cd; endfor; + trace cd; + ); + currentpicture:=nullpicture; + m=#3 div #4; + if (#3 mod #4)=0:m:=m-1; fi; + if m>0: + for l=0 upto (m-1): + fill cd shifted(l*(#1*2+0.5cm,0)) withcolor #5; + trace cd shifted(l*(#1*2+0.5cm,0)); + if #4>1: + for k=0 upto #4-1: + draw (segment(O,B[k]) cutafter cd) shifted(l*(#1*2+0.5cm,0)); + endfor; + fi; + endfor; + fi; + draw fondcolore shifted(m*(#1*2+0.5cm,0)); + draw cd shifted(m*(#1*2+0.5cm,0)); + if #4>1: + for k=0 upto #4-1: + draw (segment(O,B[k]) cutafter cd) shifted(m*(#1*2+0.5cm,0)); + endfor; fi; \end{mplibcode} \else -\begin{mpost} - pair O,A[],B[]; + \begin{mpost} + pair O,A[],B[]; O=u*(0,0); path cc,cd; cc=cercles(O,#1); @@ -1635,21 +1690,42 @@ for k=0 upto #4-1: B[k]=point(k*(#2/#4)) of cd; endfor; - remplis O--arccercle(B[0],B[#3],O)--cycle withcolor #5; - %fi; + picture fondcolore; + fondcolore=image( + remplis O--arccercle(B[0],B[#3 mod #4],O)--cycle withcolor #5; clip currentpicture to cd; - draw polygone(A0 for k=1 upto #2:,A[k] endfor); - if #4>1: for k=0 upto #4-1: draw segment(O,B[k]) cutafter cd; endfor; + trace cd; + ); + currentpicture:=nullpicture; + m=#3 div #4; + if (#3 mod #4)=0:m:=m-1; fi; + if m>0: + for l=0 upto (m-1): + fill cd shifted(l*(#1*2+0.5cm,0)) withcolor #5; + trace cd shifted(l*(#1*2+0.5cm,0)); + if #4>1: + for k=0 upto #4-1: + draw (segment(O,B[k]) cutafter cd) shifted(l*(#1*2+0.5cm,0)); + endfor; + fi; + endfor; + fi; + draw fondcolore shifted(m*(#1*2+0.5cm,0)); + draw cd shifted(m*(#1*2+0.5cm,0)); + if #4>1: + for k=0 upto #4-1: + draw (segment(O,B[k]) cutafter cd) shifted(m*(#1*2+0.5cm,0)); + endfor; fi; \end{mpost} \fi } \def\MPFractionRegulierH#1#2#3#4#5#6{% - % #1 rayon, #2 nb c\^ot\'es, #3 num, #4 deno, #5 couleur + % #1 rayon, #2 nb c\^ot\'es, #3 num, #4 deno, #5 couleur, #6 épaisseur \ifluatex \mplibforcehmode \begin{mplibcode} @@ -1664,16 +1740,42 @@ for k=0 upto #4-1: B[k]=point(k*(#2/#4)) of cd; endfor; - drawoptions(withpen pencircle scaled#6); - draw hachurage(O--arccercle(B[0],B[#3],O)--cycle,1.5*360/#2,0.25,0) withcolor #5; + picture fondcolore; + fondcolore=image(% + drawoptions(withpen pencircle scaled #6); + trace hachurage(O--arccercle(B[0],B[#3 mod #4],O)--cycle,1.5*360/#2,0.25,0) withcolor #5; clip currentpicture to cd; - drawoptions(withpen pencircle scaled#6); - draw polygone(A0 for k=1 upto #2:,A[k] endfor); - if #4>1: + drawoptions(withpen pencircle scaled #6); for k=0 upto #4-1: draw segment(O,B[k]) cutafter cd; endfor; - drawoptions(); + trace cd; + ); + currentpicture:=nullpicture; + m=#3 div #4; + if (#3 mod #4)=0:m:=m-1; fi; + if m>0: + for l=0 upto (m-1): + drawoptions(withpen pencircle scaled #6); + trace hachurage(cd shifted(l*(#1*2+0.5cm,0)),1.5*360/#2,0.25,0) withcolor #5; + drawoptions(withpen pencircle scaled #6); + trace cd shifted(l*(#1*2+0.5cm,0)); + if #4>1: + for k=0 upto #4-1: + drawoptions(withpen pencircle scaled #6); + draw (segment(O,B[k]) cutafter cd) shifted(l*(#1*2+0.5cm,0)); + endfor; + fi; + endfor; + fi; + draw fondcolore shifted(m*(#1*2+0.5cm,0)); + drawoptions(withpen pencircle scaled #6); + draw cd shifted(m*(#1*2+0.5cm,0)); + if #4>1: + drawoptions(withpen pencircle scaled #6); + for k=0 upto #4-1: + draw (segment(O,B[k]) cutafter cd) shifted(m*(#1*2+0.5cm,0)); + endfor; fi; \end{mplibcode} \else @@ -1689,16 +1791,42 @@ for k=0 upto #4-1: B[k]=point(k*(#2/#4)) of cd; endfor; - drawoptions(withpen pencircle scaled#6); - draw hachurage(O--arccercle(B[0],B[#3],O)--cycle,1.5*360/#2,0.25,0) withcolor #5; + picture fondcolore; + fondcolore=image(% + drawoptions(withpen pencircle scaled #6); + trace hachurage(O--arccercle(B[0],B[#3 mod #4],O)--cycle,1.5*360/#2,0.25,0) withcolor #5; clip currentpicture to cd; - drawoptions(withpen pencircle scaled#6); - draw polygone(A0 for k=1 upto #2:,A[k] endfor); - if #4>1: + drawoptions(withpen pencircle scaled #6); for k=0 upto #4-1: draw segment(O,B[k]) cutafter cd; endfor; - drawoptions(); + trace cd; + ); + currentpicture:=nullpicture; + m=#3 div #4; + if (#3 mod #4)=0:m:=m-1; fi; + if m>0: + for l=0 upto (m-1): + drawoptions(withpen pencircle scaled #6); + trace hachurage(cd shifted(l*(#1*2+0.5cm,0)),1.5*360/#2,0.25,0) withcolor #5; + drawoptions(withpen pencircle scaled #6); + trace cd shifted(l*(#1*2+0.5cm,0)); + if #4>1: + for k=0 upto #4-1: + drawoptions(withpen pencircle scaled #6); + draw (segment(O,B[k]) cutafter cd) shifted(l*(#1*2+0.5cm,0)); + endfor; + fi; + endfor; + fi; + draw fondcolore shifted(m*(#1*2+0.5cm,0)); + drawoptions(withpen pencircle scaled #6); + draw cd shifted(m*(#1*2+0.5cm,0)); + if #4>1: + drawoptions(withpen pencircle scaled #6); + for k=0 upto #4-1: + draw (segment(O,B[k]) cutafter cd) shifted(m*(#1*2+0.5cm,0)); + endfor; fi; \end{mpost} \fi @@ -1726,15 +1854,8 @@ S[k]=(k/#6)[B,C]; endfor; fi; - if #6=1: - remplis polygone(A,M[#3],N[#3],D) withcolor #5; - else: - DDiv=#3 div parts; - MMod=#3 mod parts; - remplis polygone(A,B,S[DDiv],R[DDiv]) withcolor #5; - remplis - polygone(R[DDiv],(xpart(M[MMod]),ypart(R[DDiv])),(xpart(M[MMod]),ypart(R[DDiv+1])),R[DDiv+1]) withcolor #5; - fi; + picture FondRectangle; + FondRectangle=image(% draw polygone(A,B,C,D); for k=1 upto (parts-1): draw segment(M[k],N[k]); @@ -1744,10 +1865,36 @@ draw segment(R[k],S[k]); endfor; fi; + ); + picture FondRectangleColorie; + FondRectangleColorie=image(% + if #6=1: + remplis polygone(A,M[#3 mod #4],N[#3 mod #4],D) withcolor #5; + else: + DDiv=(#3 mod #4) div parts; + MMod=(#3 mod #4) mod parts; + remplis polygone(A,B,S[DDiv],R[DDiv]) withcolor #5; + remplis polygone(R[DDiv],(xpart(M[MMod]),ypart(R[DDiv])),(xpart(M[MMod]),ypart(R[DDiv+1])),R[DDiv+1]) withcolor #5; + fi; + ); + m=#3 div #4; + if (#3 mod #4)=0:m:=m-1; fi; + if m>0: + for l=0 upto m-1: + remplis (polygone(A,B,C,D) shifted(l*(#1+1cm,0))) withcolor #5; + trace FondRectangle shifted(l*(#1+1cm,0)); + endfor; + fi; + if (#3 mod #4)<>0: + trace FondRectangleColorie shifted(m*(#1+1cm,0)); + else: + remplis (polygone(A,B,C,D) shifted(m*(#1+1cm,0))) withcolor #5; + fi; + trace FondRectangle shifted(m*(#1+1cm,0)); \end{mplibcode} \else \begin{mpost} - pair A,B,C,D,M[],N[],R[],S[]; + pair A,B,C,D,M[],N[],R[],S[]; A=(1,1); B-A=(#1,0); C-B=(0,#2); @@ -1764,15 +1911,8 @@ S[k]=(k/#6)[B,C]; endfor; fi; - if #6=1: - remplis polygone(A,M[#3],N[#3],D) withcolor #5; - else: - DDiv=#3 div parts; - MMod=#3 mod parts; - remplis polygone(A,B,S[DDiv],R[DDiv]) withcolor #5; - remplis - polygone(R[DDiv],(xpart(M[MMod]),ypart(R[DDiv])),(xpart(M[MMod]),ypart(R[DDiv+1])),R[DDiv+1]) withcolor #5; - fi; + picture FondRectangle; + FondRectangle=image(% draw polygone(A,B,C,D); for k=1 upto (parts-1): draw segment(M[k],N[k]); @@ -1782,6 +1922,32 @@ draw segment(R[k],S[k]); endfor; fi; + ); + picture FondRectangleColorie; + FondRectangleColorie=image(% + if #6=1: + remplis polygone(A,M[#3 mod #4],N[#3 mod #4],D) withcolor #5; + else: + DDiv=(#3 mod #4) div parts; + MMod=(#3 mod #4) mod parts; + remplis polygone(A,B,S[DDiv],R[DDiv]) withcolor #5; + remplis polygone(R[DDiv],(xpart(M[MMod]),ypart(R[DDiv])),(xpart(M[MMod]),ypart(R[DDiv+1])),R[DDiv+1]) withcolor #5; + fi; + ); + m=#3 div #4; + if (#3 mod #4)=0:m:=m-1; fi; + if m>0: + for l=0 upto m-1: + remplis (polygone(A,B,C,D) shifted(l*(#1+1cm,0))) withcolor #5; + trace FondRectangle shifted(l*(#1+1cm,0)); + endfor; + fi; + if (#3 mod #4)<>0: + trace FondRectangleColorie shifted(m*(#1+1cm,0)); + else: + remplis (polygone(A,B,C,D) shifted(m*(#1+1cm,0))) withcolor #5; + fi; + trace FondRectangle shifted(m*(#1+1cm,0)); \end{mpost} \fi } @@ -1808,18 +1974,8 @@ S[k]=(k/#6)[B,C]; endfor; fi; - if #6=1: - drawoptions(withpen pencircle scaled#7); - draw hachurage(polygone(A,M[#3],N[#3],D),45,0.25,0) withcolor #5; - else: - DDiv=#3 div parts; - MMod=#3 mod parts; - drawoptions(withpen pencircle scaled#7); - draw hachurage(polygone(A,B,S[DDiv],R[DDiv]),45,0.25,0) withcolor #5; - drawoptions(withpen pencircle scaled#7); - draw hachurage(polygone(R[DDiv],(xpart(M[MMod]),ypart(R[DDiv])),(xpart(M[MMod]),ypart(R[DDiv+1])),R[DDiv+1]),45,0.25,0) withcolor #5; - fi; - drawoptions(withpen pencircle scaled#7); + picture FondRectangle; + FondRectangle=image(% draw polygone(A,B,C,D); for k=1 upto (parts-1): draw segment(M[k],N[k]); @@ -1828,8 +1984,41 @@ for k=1 upto (#6-1): draw segment(R[k],S[k]); endfor; - drawoptions(); fi; + ); + picture FondRectangleColorie; + FondRectangleColorie=image(% + if #6=1: + drawoptions(withpen pencircle scaled#7); + trace hachurage(polygone(A,M[#3 mod #4],N[#3 mod #4],D),45,0.25,0) withcolor #5; + else: + DDiv=(#3 mod #4) div parts; + MMod=(#3 mod #4) mod parts; + drawoptions(withpen pencircle scaled#7); + trace hachurage(polygone(A,B,S[DDiv],R[DDiv]),45,0.25,0) withcolor #5; + drawoptions(withpen pencircle scaled#7); + trace hachurage(polygone(R[DDiv],(xpart(M[MMod]),ypart(R[DDiv])),(xpart(M[MMod]),ypart(R[DDiv+1])),R[DDiv+1]),45,0.25,0) withcolor #5; + fi; + ); + m=#3 div #4; + if (#3 mod #4)=0:m:=m-1; fi; + if m>0: + for l=0 upto m-1: + drawoptions(withpen pencircle scaled#7); + trace hachurage(polygone(A,B,C,D) shifted(l*(#1+1cm,0)),45,0.25,0) withcolor #5; + drawoptions(withpen pencircle scaled#7); + trace FondRectangle shifted(l*(#1+1cm,0)); + endfor; + fi; + if (#3 mod #4)<>0: + drawoptions(withpen pencircle scaled#7); + trace FondRectangleColorie shifted(m*(#1+1cm,0)); + else: + drawoptions(withpen pencircle scaled#7); + trace hachurage(polygone(A,B,C,D) shifted(m*(#1+1cm,0)),45,0.25,0) withcolor #5; + fi; + drawoptions(withpen pencircle scaled#7); + trace FondRectangle shifted(m*(#1+1cm,0)); \end{mplibcode} \else \begin{mpost} @@ -1884,13 +2073,22 @@ A=(0,0); path cc; cc=cercles(A,#1); - for k=0 upto (#3-1): + for k=0 upto #3: B[k]=pointarc(cc,(360/#3)*k); endfor; - fill (A--B0--arccercle(B[0],B[#2],A)--cycle) withcolor #4; - draw cc; + m=(#2 div #3); + if (#2 mod #3)=0:m:=m-1; fi; + if m>0: + for l=0 upto (m-1): + fill cc shifted(l*(2*#1+1cm,0)) withcolor #4; + endfor; + fi; + fill ((A--B0--arccercle(B[0],B[#2 mod #3],A)--cycle) shifted (m*(2*#1+1cm,0))) withcolor #4; + for l=0 upto m: + draw cc shifted(l*(2*#1+1cm,0)); for k=0 upto (#3-1): - draw segment(A,B[k]); + draw segment(A,B[k]) shifted(l*(2*#1+1cm,0)); + endfor; endfor; \end{mplibcode} \else @@ -1899,13 +2097,22 @@ A=(0,0); path cc; cc=cercles(A,#1); - for k=0 upto (#3-1): + for k=0 upto #3: B[k]=pointarc(cc,(360/#3)*k); endfor; - fill (A--B0--arccercle(B[0],B[#2],A)--cycle) withcolor #4; - draw cc; + m=#2 div #3; + if (#2 mod #3)=0:m:=m-1; fi; + if m>0: + for l=0 upto (m-1): + fill cc shifted(l*(2*#1+1cm,0)) withcolor #4; + endfor; + fi; + fill ((A--B0--arccercle(B[0],B[#2 mod #3],A)--cycle) shifted (m*(2*#1+1cm,0))) withcolor #4; + for l=0 upto m: + draw cc shifted(l*(2*#1+1cm,0)); for k=0 upto (#3-1): - draw segment(A,B[k]); + draw segment(A,B[k]) shifted(l*(2*#1+1cm,0)); + endfor; endfor; \end{mpost} \fi @@ -1919,17 +2126,26 @@ A=(0,0); path cc; cc=cercles(A,#1); - for k=0 upto (#3-1): + for k=0 upto #3: B[k]=pointarc(cc,(360/#3)*k); endfor; + m=#2 div #3; + if (#2 mod #3)=0:m:=m-1; fi; + if m>0: + for l=0 upto (m-1): drawoptions(withpen pencircle scaled#5); - draw hachurage(A--B0--arccercle(B[0],B[#2],A)--cycle,1.5*360/#3,0.25,0) withcolor #4; + draw hachurage(cc shifted(l*(2*#1+1cm,0)),1.5*360/#3,0.25,0) withcolor #4; + endfor; + fi; drawoptions(withpen pencircle scaled#5); - draw cc; + draw hachurage((A--B0--arccercle(B[0],B[#2 mod #3],A)--cycle) shifted(m*(2*#1+1cm,0)),1.5*360/#3,0.25,0) withcolor #4; + drawoptions(withpen pencircle scaled#5); + for l=0 upto m: + draw cc shifted(l*(2*#1+1cm,0)); for k=0 upto (#3-1): - draw segment(A,B[k]); + draw segment(A,B[k]) shifted(l*(2*#1+1cm,0)); + endfor; endfor; - drawoptions(); \end{mplibcode} \else \begin{mpost} @@ -1937,17 +2153,26 @@ A=(0,0); path cc; cc=cercles(A,#1); - for k=0 upto (#3-1): + for k=0 upto #3: B[k]=pointarc(cc,(360/#3)*k); endfor; + m=#2 div #3; + if (#2 mod #3)=0:m:=m-1; fi; + if m>0: + for l=0 upto (m-1): + drawoptions(withpen pencircle scaled#5); + draw hachurage(cc shifted(l*(2*#1+1cm,0)),1.5*360/#3,0.25,0) withcolor #4; + endfor; + fi; drawoptions(withpen pencircle scaled#5); - draw hachurage(A--B0--arccercle(B[0],B[#2],A)--cycle,1.5*360/#3,0.25,0) withcolor #4; + draw hachurage((A--B0--arccercle(B[0],B[#2 mod #3],A)--cycle) shifted(m*(2*#1+1cm,0)),1.5*360/#3,0.25,0) withcolor #4; drawoptions(withpen pencircle scaled#5); - draw cc; + for l=0 upto m: + draw cc shifted(l*(2*#1+1cm,0)); for k=0 upto (#3-1): - draw segment(A,B[k]); + draw segment(A,B[k]) shifted(l*(2*#1+1cm,0)); + endfor; endfor; - drawoptions(); \end{mpost} \fi } @@ -1962,32 +2187,62 @@ for k=0 upto #3: B[k]=(k/#3)[A,C]; endfor; - draw segment(B[0],B[#2]) withpen pencircle scaled 2 withcolor #4; - draw segment(A,C); + m=#2 div #3; + if m>0: + for l=0 upto (m-1): + draw (segment(B[0],B[#3]) shifted(l*(#1+1cm,0))) withpen pencircle scaled 2 withcolor #4; + endfor; + fi; + if (#2 mod #3)<>0: + draw (segment(B[0],B[#2 mod #3]) shifted(m*(#1+1cm,0))) withpen pencircle scaled 2 withcolor #4; + draw segment(A,C) shifted(m*(#1+1cm,0)); + fi; marque_p:="tiretv"; + for l=0 upto m-1: for k=0 upto #3: - pointe(B[k]); + pointe(B[k] shifted(l*(#1+1cm,0))); + endfor; endfor; + if (#2 mod #3)<>0: + for k=0 upto #3: + pointe(B[k] shifted(m*(#1+1cm,0))); + endfor; + fi; \end{mplibcode} \else \begin{mpost} - pair A,C,B[]; + pair A,C,B[]; A=(0,0); C-A=(#1,0); for k=0 upto #3: B[k]=(k/#3)[A,C]; endfor; - draw segment(B[0],B[#2]) withpen pencircle scaled 2 withcolor #4; - draw segment(A,C); + m=#2 div #3; + if m>0: + for l=0 upto (m-1): + draw (segment(B[0],B[#3]) shifted(l*(#1+1cm,0))) withpen pencircle scaled 2 withcolor #4; + endfor; + fi; + if (#2 mod #3)<>0: + draw (segment(B[0],B[#2 mod #3]) shifted(m*(#1+1cm,0))) withpen pencircle scaled 2 withcolor #4; + draw segment(A,C) shifted(m*(#1+1cm,0)); + fi; marque_p:="tiretv"; + for l=0 upto m-1: for k=0 upto #3: - pointe(B[k]); + pointe(B[k] shifted(l*(#1+1cm,0))); endfor; + endfor; + if (#2 mod #3)<>0: + for k=0 upto #3: + pointe(B[k] shifted(m*(#1+1cm,0))); + endfor; + fi; \end{mpost} \fi } -\def\MPFractionSegmentH#1#2#3#4#5{ +\def\MPFractionSegmentH#1#2#3#4#5{% \ifluatex \mplibforcehmode \begin{mplibcode} @@ -1997,33 +2252,67 @@ for k=0 upto #3: B[k]=(k/#3)[A,C]; endfor; + m=#2 div #3; + if m>0: + for l=0 upto (m-1): drawoptions(withpen pencircle scaled#5); - draw hachurage(polygone(B[0]+u*(0,-0.15),B[#2]+u*(0,-0.15),B[#2]+u*(0,0.15),B[0]+u*(0,0.15)),120,0.2,0) - withcolor #4; + draw hachurage(polygone(B[0]+u*(0,-0.15),B[#3]+u*(0,-0.15),B[#3]+u*(0,0.15),B[0]+u*(0,0.15)) shifted(l*(#1+1cm,0)),120,0.2,0) withcolor #4; drawoptions(withpen pencircle scaled#5); - draw segment(A,C); + draw segment(A,C) shifted(l*(#1+1cm,0)); + endfor; + fi; + if (#2 mod #3)<>0: + drawoptions(withpen pencircle scaled#5); + draw hachurage(polygone(B[0]+u*(0,-0.15),B[#2 mod #3]+u*(0,-0.15),B[#2 mod #3]+u*(0,0.15),B[0]+u*(0,0.15)) shifted(m*(#1+1cm,0)),120,0.2,0) withcolor #4; + drawoptions(withpen pencircle scaled#5); + draw segment(A,C) shifted(m*(#1+1cm,0)); + fi; marque_p:="tiretv"; + for l=0 upto m-1: + for k=0 upto #3: + pointe(B[k] shifted(l*(#1+1cm,0))); + endfor; + endfor; + if (#2 mod #3)<>0: for k=0 upto #3: - pointe(B[k]); + pointe(B[k] shifted(m*(#1+1cm,0))); endfor; + fi; \end{mplibcode} \else \begin{mpost} - pair A,C,B[]; + pair A,C,B[]; A=(0,0); C-A=(#1,0); for k=0 upto #3: B[k]=(k/#3)[A,C]; endfor; + m=#2 div #3; + if m>0: + for l=0 upto (m-1): drawoptions(withpen pencircle scaled#5); - draw hachurage(polygone(B[0]+u*(0,-0.15),B[#2]+u*(0,-0.15),B[#2]+u*(0,0.15),B[0]+u*(0,0.15)),120,0.2,0) - withcolor #4; + draw hachurage(polygone(B[0]+u*(0,-0.15),B[#3]+u*(0,-0.15),B[#3]+u*(0,0.15),B[0]+u*(0,0.15)) shifted(l*(#1+1cm,0)),120,0.2,0) withcolor #4; drawoptions(withpen pencircle scaled#5); - draw segment(A,C); + draw segment(A,C) shifted(l*(#1+1cm,0)); + endfor; + fi; + if (#2 mod #3)<>0: + drawoptions(withpen pencircle scaled#5); + draw hachurage(polygone(B[0]+u*(0,-0.15),B[#2 mod #3]+u*(0,-0.15),B[#2 mod #3]+u*(0,0.15),B[0]+u*(0,0.15)) shifted(m*(#1+1cm,0)),120,0.2,0) withcolor #4; + drawoptions(withpen pencircle scaled#5); + draw segment(A,C) shifted(m*(#1+1cm,0)); + fi; marque_p:="tiretv"; + for l=0 upto m-1: + for k=0 upto #3: + pointe(B[k] shifted(l*(#1+1cm,0))); + endfor; + endfor; + if (#2 mod #3)<>0: for k=0 upto #3: - pointe(B[k]); + pointe(B[k] shifted(m*(#1+1cm,0))); endfor; + fi; \end{mpost} \fi } @@ -2209,10 +2498,75 @@ }% } +\newcommand\QCMVar[2][]{% + \useKVdefault[ClesQCM]% + \setKV[ClesQCM]{#1}% + \setcounter{QuestionQCM}{\fpeval{\useKV[ClesQCM]{Depart}-1}}% + \setcounter{TitreQCM}{0} + \setsepchar[*]{§*&}\ignoreemptyitems% + \readlist*\ListeQCM{#2}% + \ifboolKV[ClesQCM]{Multiple}{% + \renewcommand{\arraystretch}{\useKV[ClesQCM]{Stretch}}% + \setlength{\LargeurQCM}{\fpeval{(\linewidth-\useKV[ClesQCM]{Reponses}*(3*\tabcolsep+\useKV[ClesQCM]{Largeur}))}pt}% + \xdef\NBcases{\fpeval{\useKV[ClesQCM]{Reponses}+1}}% + \xdef\ListeNom{\useKV[ClesQCM]{Noms}}% + \setsepchar[*]{/}% + \readlist*\ListeNomsMul{\ListeNom}% + \begin{tabular}{|p{\LargeurQCM}|*{\useKV[ClesQCM]{Reponses}}{>{\centering\arraybackslash}p{\useKV[ClesQCM]{Largeur}}|}}% + \cline{2-\NBcases}% + \multicolumn{1}{c|}{}\xintFor* ##2 in {\xintSeq {1}{\useKV[ClesQCM]{Reponses}}}\do{% + &\ListeNomsMul[##2]}% + \\ + \hline% + \xintFor* ##1 in {\xintSeq {1}{\ListeQCMlen}}\do{% + \stepcounter{QuestionQCM}\ifboolKV[ClesQCM]{Alterne}{\modulo{\theQuestionQCM}{2}\ifnum\remainder=0\cellcolor{gray!15}\fi}{}\ifboolKV[ClesQCM]{Alph}{\textbf{\Alph{QuestionQCM}}/}{\textbf{\theQuestionQCM/}}~\ListeQCM[##1,1]\xintFor* ##2 in {\xintSeq {1}{\useKV[ClesQCM]{Reponses}}}\do{% + &\ifboolKV[ClesQCM]{Alterne}{\modulo{\theQuestionQCM}{2}\ifnum\remainder=0\cellcolor{gray!15}\fi}{}\ifboolKV[ClesQCM]{Solution}{\xintifboolexpr{\ListeQCM[##1,\fpeval{##2+1}]=1}{$\boxtimes$}{$\square$}}{$\square$}% + }\\ + }% + \hline% + \end{tabular}% + }{% + \ifboolKV[ClesQCM]{VF}{% + \setKV[ClesQCM]{Reponses=2} + \renewcommand{\arraystretch}{\useKV[ClesQCM]{Stretch}}% + \setlength{\LargeurQCM}{\fpeval{(\linewidth-\useKV[ClesQCM]{Reponses}*(3*\tabcolsep+\useKV[ClesQCM]{Largeur}))}pt}% + \xdef\NBcases{\fpeval{\useKV[ClesQCM]{Reponses}+1}}% + \begin{tabular}{|p{\LargeurQCM}|*{\useKV[ClesQCM]{Reponses}}{>{\centering\arraybackslash}p{\useKV[ClesQCM]{Largeur}}|}}% + \cline{2-\NBcases}% + \multicolumn{1}{c|}{}&\useKV[ClesQCM]{NomV}&\useKV[ClesQCM]{NomF}\\ + \hline% + \xintFor* ##1 in {\xintSeq {1}{\ListeQCMlen}}\do{% + \stepcounter{QuestionQCM}\ifboolKV[ClesQCM]{Alterne}{\modulo{\theQuestionQCM}{2}\ifnum\remainder=0\cellcolor{gray!15}\fi}{}\ifboolKV[ClesQCM]{Alph}{\textbf{\Alph{QuestionQCM}}/}{\textbf{\theQuestionQCM/}}~\ListeQCM[##1,1]\xintFor* ##2 in {\xintSeq {1}{\useKV[ClesQCM]{Reponses}}}\do{% + &\ifboolKV[ClesQCM]{Alterne}{\modulo{\theQuestionQCM}{2}\ifnum\remainder=0\cellcolor{gray!15}\fi}{}\ifboolKV[ClesQCM]{Solution}{\xintifboolexpr{##2=\ListeQCM[##1,2]}{$\boxtimes$}{$\square$}}{$\square$}% + }\\ + }% + \hline% + \end{tabular} + }{% + \renewcommand{\arraystretch}{\useKV[ClesQCM]{Stretch}}% + \setlength{\LargeurQCM}{\fpeval{(\linewidth-\useKV[ClesQCM]{Reponses}*(3*\tabcolsep+\useKV[ClesQCM]{Largeur}))}pt}% + \xdef\NBcases{\fpeval{\useKV[ClesQCM]{Reponses}+1}}% + \begin{tabular}{|p{\LargeurQCM}|*{\useKV[ClesQCM]{Reponses}}{>{\centering\arraybackslash}p{\useKV[ClesQCM]{Largeur}}|}}% + \ifboolKV[ClesQCM]{Titre}{\cline{2-\NBcases}% + \multicolumn{1}{c|}{}\xintFor* ##2 in {\xintSeq {1}{\useKV[ClesQCM]{Reponses}}}\do{% + &\stepcounter{TitreQCM}\useKV[ClesQCM]{Nom} \ifboolKV[ClesQCM]{AlphT}{\Alph{TitreQCM}}{##2}}% + \\ + }{} + \hline% + \xintFor* ##1 in {\xintSeq {1}{\ListeQCMlen}}\do{% + \stepcounter{QuestionQCM}\ifboolKV[ClesQCM]{Alterne}{\modulo{\theQuestionQCM}{2}\ifnum\remainder=0\cellcolor{gray!15}\fi}{}\ifboolKV[ClesQCM]{Alph}{\textbf{\Alph{QuestionQCM}}/}{\textbf{\theQuestionQCM/}}~\ListeQCM[##1,1]\xintFor* ##2 in {\xintSeq {1}{\useKV[ClesQCM]{Reponses}}}\do{% + &\ifboolKV[ClesQCM]{Alterne}{\modulo{\theQuestionQCM}{2}\ifnum\remainder=0\cellcolor{gray!15}\fi}{}\ifboolKV[ClesQCM]{Solution}{\xdef\NumeroReponse{\fpeval{\useKV[ClesQCM]{Reponses}+2}}\xintifboolexpr{##2=\ListeQCM[##1,\NumeroReponse]}{\cellcolor{\useKV[ClesQCM]{Couleur}}}{}}{}\ListeQCM[##1,##2+1]% + }\\ + }% + \hline% + \end{tabular}% + }% + }% +} + %%% % Somme des angles %%% - \setKVdefault[ClesSommeAngle]{Detail=true,Isocele=false,Figure=false,FigureSeule=false,Angle=0,Perso=false}% \def\MPFigureSommeAngle#1#2#3#4#5#6#7{ @@ -2868,7 +3222,326 @@ % y a dans un "seul calcul". \setcounter{NbCalculDistri}{0} -\setKVdefault[ClesDistributivite]{Etape=1,Lettre=x,Fleches=false,AideMul=false,Reduction=false,AideAdda=false,AideAddb=false,CouleurAide=red,CouleurReduction=black,CouleurFH=blue,CouleurFB=red,Somme=false,Difference=false,RAZ=false,Oppose=false,All=false,NomExpression=A,Fin=4,Numerique=false,Remarquable=false,Echange=0}%,AideAdd=false:inutile ? +\setKVdefault[ClesDistributivite]{Etape=1,Lettre=x,Fleches=false,AideMul=false,Reduction=false,AideAdda=false,AideAddb=false,CouleurAide=red,CouleurReduction=black,CouleurFH=blue,CouleurFB=red,Somme=false,Difference=false,RAZ=false,Oppose=false,All=false,NomExpression=A,Fin=4,Numerique=false,Remarquable=false,Echange=0,Tuile=false,Vide=false}%,AideAdd=false:inutile ? + +\newcommand\Tuile[4]{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + boolean Vide; + Vide=\useKV[ClesDistributivite]{Vide}; + pair _CoinTuilev; + _CoinTuilev=(0,0); + numeric largeur,longueur,ecart; + largeur=0.75; + longueur=sqrt(3); + ecart=0.6; + pair _CoinTuileh; + _CoinTuileh=u*(largeur+ecart,ecart); + vardef tuilev(expr LL,ll,nb,col)(text t)= + save $; picture $; + save TT; picture TT; + TT=image( + path cc; + cc=polygone((0,0),u*(LL,0),u*(LL,-ll),u*(0,-ll)); + fill cc withcolor col; + trace cc; + label(TEX(t),iso((0,0),u*(LL,0),u*(LL,-ll),u*(0,-ll))); + ); + $=image( + for k=0 upto nb-1: + trace TT shifted(_CoinTuilev+k*u*(0,-ll)); + endfor; + _CoinTuilev:=_CoinTuilev shifted(nb*u*(0,-ll)); + ); + $ + enddef; + vardef tuileh(expr LL,ll,nb,col)(text t)= + save $; picture $; + picture TT; + TT=image( + path cc; + cc=polygone((0,0),u*(LL,0),u*(LL,ll),u*(0,ll)); + fill cc withcolor col; + trace cc; + label(TEX(t),iso((0,0),u*(LL,0),u*(LL,ll),u*(0,ll))); + ); + $=image( + for k=0 upto nb-1: + trace TT shifted(_CoinTuileh+k*u*(LL,0)); + endfor; + _CoinTuileh:=_CoinTuileh shifted(nb*u*(LL,0)); + ); + $ + enddef; + color ColorLetter,ColorLetterPos,ColorLetterNeg,ColorNum,ColorNumPos,ColorNumNeg,ColorCarrePos,ColorCarreNeg; + ColorLetter=LightGreen; + ColorLetterPos=ColorLetter; + ColorLetterNeg=Tomato; + ColorNum=Orange; + ColorNumPos=ColorNum; + ColorNumNeg=Tomato; + ColorCarrePos:=LightBlue; + ColorCarreNeg:=Tomato; + if #1<0: + ColorLetter:=Tomato; + trace tuilev(largeur,longueur,abs(#1),ColorLetter)("$-x$"); + else: + ColorLetter:=LightGreen; + trace tuilev(largeur,longueur,abs(#1),ColorLetter)("$x$"); + fi; + if #2<0: + ColorNum:=Tomato; + trace tuilev(largeur,largeur,abs(#2),ColorNum)("$-1$"); + else: + ColorNum:=Orange; + trace tuilev(largeur,largeur,abs(#2),ColorNum)("$1$"); + fi; + if #3<0: + ColorLetter:=Tomato; + trace tuileh(longueur,largeur,abs(#3),ColorLetter)("$-x$"); + else: + ColorLetter:=LightGreen; + trace tuileh(longueur,largeur,abs(#3),ColorLetter)("$x$"); + fi; + if #4<0: + ColorNum:=Tomato; + trace tuileh(largeur,largeur,abs(#4),ColorNum)("$-1$"); + else: + ColorNum:=Orange; + trace tuileh(largeur,largeur,abs(#4),ColorNum)("$1$"); + fi; + trace u*(largeur+ecart/2,largeur+ecart)--((largeur+ecart/2)*u,ypart(_CoinTuilev)) withpen pencircle scaled2; + trace u*(0,ecart/2)--(xpart(_CoinTuileh),u*(ecart/2)) withpen pencircle scaled2; + drawarrow u*(largeur/2,ecart/2){dir90}..{dir0}u*(largeur+ecart/2,largeur/2+ecart) withpen pencircle scaled2; + labeloffset:=labeloffset*2; + label.ulft(TEX("$\times$"),iso(u*(largeur/2,ecart/2),u*(largeur+ecart/2,largeur/2+ecart))); + labeloffset:=labeloffset/2; + if Vide=false: + %% tuile a*c + if #1*#3<>0: + for k=0 upto (abs(#3)-1): + for l=0 upto (abs(#1)-1): + path titi; + titi=polygone((0,0),u*(longueur,0),u*(longueur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart,0)+(u*(k*longueur,-l*longueur))); + fill titi withcolor if #1*#3>0:ColorCarrePos else: ColorCarreNeg fi; + trace titi; + if #1*#3>0: + label(TEX("$x^2$"),iso((0,0),u*(longueur,0),u*(longueur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart,0)+(u*(k*longueur,-l*longueur)))); + else: + label(TEX("$-x^2$"),iso((0,0),u*(longueur,0),u*(longueur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart,0)+(u*(k*longueur,-l*longueur)))); + fi; + endfor; + endfor; + fi; + %tuile a*d + if #1*#4<>0: + for k=0 upto (abs(#4)-1): + for l=0 upto (abs(#1)-1): + path titi; + titi=polygone((0,0),u*(largeur,0),u*(largeur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart+abs(#3)*longueur,0)+(u*(k*largeur,-l*longueur))); + fill titi withcolor if #1*#4>0:ColorLetterPos else: ColorLetterNeg fi; + trace titi; + if #1*#4>0: + label(TEX("$x$"),iso((0,0),u*(largeur,0),u*(largeur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart+abs(#3)*longueur,0)+(u*(k*largeur,-l*longueur)))); + else: + label(TEX("$-x$"),iso((0,0),u*(largeur,0),u*(largeur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart+abs(#3)*longueur,0)+(u*(k*largeur,-l*longueur)))); + fi; + endfor; + endfor; + fi; + %tuile b*c + if #2*#3<>0: + for k=0 upto (abs(#3)-1): + for l=0 upto (abs(#2)-1): + path titi; + titi=polygone((0,0),u*(longueur,0),u*(longueur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart,-abs(#1)*longueur)+(u*(k*longueur,-l*largeur))); + fill titi withcolor if #2*#3>0:ColorLetterPos else: ColorLetterNeg fi; + trace titi; + if #2*#3>0: + label(TEX("$x$"),iso((0,0),u*(longueur,0),u*(longueur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart,-abs(#1)*longueur)+(u*(k*longueur,-l*largeur)))); + else: + label(TEX("$-x$"),iso((0,0),u*(longueur,0),u*(longueur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart,-abs(#1)*longueur)+(u*(k*longueur,-l*largeur)))); + fi; + endfor; + endfor; + fi; + %tuile b*d + if #2*#4<>0: + for k=0 upto (abs(#4)-1): + for l=0 upto (abs(#2)-1): + path titi; + titi=polygone((0,0),u*(largeur,0),u*(largeur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart+abs(#3)*longueur,-abs(#1)*longueur)+(u*(k*largeur,-l*largeur))); + fill titi withcolor if #2*#4>0:ColorNumPos else: ColorNumNeg fi; + trace titi; + if #2*#4>0: + label(TEX("$1$"),iso((0,0),u*(largeur,0),u*(largeur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart+abs(#3)*longueur,-abs(#1)*longueur)+(u*(k*largeur,-l*largeur)))); + else: + label(TEX("$-1$"),iso((0,0),u*(largeur,0),u*(largeur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart+abs(#3)*longueur,-abs(#1)*longueur)+(u*(k*largeur,-l*largeur)))); + fi; + endfor; + endfor; + fi; + fi; + \end{mplibcode} + \else + \begin{mpost}[mpsettings={boolean Vide; Vide=\useKV[ClesDistributivite]{Vide};}] + pair _CoinTuilev; + _CoinTuilev=(0,0); + numeric largeur,longueur,ecart; + largeur=0.75; + longueur=sqrt(3); + ecart=0.6; + pair _CoinTuileh; + _CoinTuileh=u*(largeur+ecart,ecart); + vardef tuilev(expr LL,ll,nb,col)(text t)= + save $; picture $; + save TT; picture TT; + TT=image( + path cc; + cc=polygone((0,0),u*(LL,0),u*(LL,-ll),u*(0,-ll)); + fill cc withcolor col; + trace cc; + label(LATEX(t),iso((0,0),u*(LL,0),u*(LL,-ll),u*(0,-ll))); + ); + $=image( + for k=0 upto nb-1: + trace TT shifted(_CoinTuilev+k*u*(0,-ll)); + endfor; + _CoinTuilev:=_CoinTuilev shifted(nb*u*(0,-ll)); + ); + $ + enddef; + vardef tuileh(expr LL,ll,nb,col)(text t)= + save $; picture $; + picture TT; + TT=image( + path cc; + cc=polygone((0,0),u*(LL,0),u*(LL,ll),u*(0,ll)); + fill cc withcolor col; + trace cc; + label(LATEX(t),iso((0,0),u*(LL,0),u*(LL,ll),u*(0,ll))); + ); + $=image( + for k=0 upto nb-1: + trace TT shifted(_CoinTuileh+k*u*(LL,0)); + endfor; + _CoinTuileh:=_CoinTuileh shifted(nb*u*(LL,0)); + ); + $ + enddef; + color ColorLetter,ColorLetterPos,ColorLetterNeg,ColorNum,ColorNumPos,ColorNumNeg,ColorCarrePos,ColorCarreNeg; + ColorLetter=LightGreen; + ColorLetterPos=ColorLetter; + ColorLetterNeg=Tomato; + ColorNum=Orange; + ColorNumPos=ColorNum; + ColorNumNeg=Tomato; + ColorCarrePos:=LightBlue; + ColorCarreNeg:=Tomato; + if #1<0: + ColorLetter:=Tomato; + trace tuilev(largeur,longueur,abs(#1),ColorLetter)("$-x$"); + else: + ColorLetter:=LightGreen; + trace tuilev(largeur,longueur,abs(#1),ColorLetter)("$x$"); + fi; + if #2<0: + ColorNum:=Tomato; + trace tuilev(largeur,largeur,abs(#2),ColorNum)("$-1$"); + else: + ColorNum:=Orange; + trace tuilev(largeur,largeur,abs(#2),ColorNum)("$1$"); + fi; + if #3<0: + ColorLetter:=Tomato; + trace tuileh(longueur,largeur,abs(#3),ColorLetter)("$-x$"); + else: + ColorLetter:=LightGreen; + trace tuileh(longueur,largeur,abs(#3),ColorLetter)("$x$"); + fi; + if #4<0: + ColorNum:=Tomato; + trace tuileh(largeur,largeur,abs(#4),ColorNum)("$-1$"); + else: + ColorNum:=Orange; + trace tuileh(largeur,largeur,abs(#4),ColorNum)("$1$"); + fi; + trace u*(largeur+ecart/2,largeur+ecart)--((largeur+ecart/2)*u,ypart(_CoinTuilev)) withpen pencircle scaled2; + trace u*(0,ecart/2)--(xpart(_CoinTuileh),u*(ecart/2)) withpen pencircle scaled2; + drawarrow u*(largeur/2,ecart/2){dir90}..{dir0}u*(largeur+ecart/2,largeur/2+ecart) withpen pencircle scaled2; + labeloffset:=labeloffset*2; + label.ulft(LATEX("$\times$"),iso(u*(largeur/2,ecart/2),u*(largeur+ecart/2,largeur/2+ecart))); + labeloffset:=labeloffset/2; + if Vide=false: + %% tuile a*c + if #1*#3<>0: + for k=0 upto (abs(#3)-1): + for l=0 upto (abs(#1)-1): + path titi; + titi=polygone((0,0),u*(longueur,0),u*(longueur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart,0)+(u*(k*longueur,-l*longueur))); + fill titi withcolor if #1*#3>0:ColorCarrePos else: ColorCarreNeg fi; + trace titi; + if #1*#3>0: + label(LATEX("$x^2$"),iso((0,0),u*(longueur,0),u*(longueur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart,0)+(u*(k*longueur,-l*longueur)))); + else: + label(LATEX("$-x^2$"),iso((0,0),u*(longueur,0),u*(longueur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart,0)+(u*(k*longueur,-l*longueur)))); + fi; + endfor; + endfor; + fi; + %tuile a*d + if #1*#4<>0: + for k=0 upto (abs(#4)-1): + for l=0 upto (abs(#1)-1): + path titi; + titi=polygone((0,0),u*(largeur,0),u*(largeur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart+abs(#3)*longueur,0)+(u*(k*largeur,-l*longueur))); + fill titi withcolor if #1*#4>0:ColorLetterPos else: ColorLetterNeg fi; + trace titi; + if #1*#4>0: + label(LATEX("$x$"),iso((0,0),u*(largeur,0),u*(largeur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart+abs(#3)*longueur,0)+(u*(k*largeur,-l*longueur)))); + else: + label(LATEX("$-x$"),iso((0,0),u*(largeur,0),u*(largeur,-longueur),u*(0,-longueur)) shifted (u*(largeur+ecart+abs(#3)*longueur,0)+(u*(k*largeur,-l*longueur)))); + fi; + endfor; + endfor; + fi; + %tuile b*c + if #2*#3<>0: + for k=0 upto (abs(#3)-1): + for l=0 upto (abs(#2)-1): + path titi; + titi=polygone((0,0),u*(longueur,0),u*(longueur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart,-abs(#1)*longueur)+(u*(k*longueur,-l*largeur))); + fill titi withcolor if #2*#3>0:ColorLetterPos else: ColorLetterNeg fi; + trace titi; + if #2*#3>0: + label(LATEX("$x$"),iso((0,0),u*(longueur,0),u*(longueur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart,-abs(#1)*longueur)+(u*(k*longueur,-l*largeur)))); + else: + label(LATEX("$-x$"),iso((0,0),u*(longueur,0),u*(longueur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart,-abs(#1)*longueur)+(u*(k*longueur,-l*largeur)))); + fi; + endfor; + endfor; + fi; + %tuile b*d + if #2*#4<>0: + for k=0 upto (abs(#4)-1): + for l=0 upto (abs(#2)-1): + path titi; + titi=polygone((0,0),u*(largeur,0),u*(largeur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart+abs(#3)*longueur,-abs(#1)*longueur)+(u*(k*largeur,-l*largeur))); + fill titi withcolor if #2*#4>0:ColorNumPos else: ColorNumNeg fi; + trace titi; + if #2*#4>0: + label(LATEX("$1$"),iso((0,0),u*(largeur,0),u*(largeur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart+abs(#3)*longueur,-abs(#1)*longueur)+(u*(k*largeur,-l*largeur)))); + else: + label(LATEX("$-1$"),iso((0,0),u*(largeur,0),u*(largeur,-largeur),u*(0,-largeur)) shifted (u*(largeur+ecart+abs(#3)*longueur,-abs(#1)*longueur)+(u*(k*largeur,-l*largeur)))); + fi; + endfor; + endfor; + fi; + fi; + \end{mpost} + \fi +} \newcommand\Affichage[4][]{% \setKV[ClesDistributivite]{#1}%On lit les arguments optionnels @@ -2892,191 +3565,195 @@ \xdef\SommeC{0}% \newcommand{\Distri}[5][]{% - \ensuremath{% - \useKVdefault[ClesDistributivite]%obligatoire car la macro n'est pas dans un groupe. - \setKV[ClesDistributivite]{#1}%On lit les arguments optionnels - \ifboolKV[ClesDistributivite]{RAZ}{\xdef\SommeA{0}\xdef\SommeB{0}\xdef\SommeC{0}% - \setcounter{NbCalculDistri}{0}% - }{}% - \colorlet{DCAide}{\useKV[ClesDistributivite]{CouleurAide}}% - \colorlet{DCReduction}{\useKV[ClesDistributivite]{CouleurReduction}}% - \colorlet{DCFlechesh}{\useKV[ClesDistributivite]{CouleurFH}}% - \colorlet{DCFlechesb}{\useKV[ClesDistributivite]{CouleurFB}}% - \xintifboolexpr{\useKV[ClesDistributivite]{Echange}>0}{% - \DistriEchange[#1]{#2}{#3}{#4}{#5}% - }{% - \ifboolKV[ClesDistributivite]{Remarquable}{% - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=1}{% - \ifx\bla#4\bla(\Affichage{0}{#2}{#3})^2\else(\Affichage{0}{#2}{#3})(\Affichage{0}{#4}{#5})\fi% - }{} - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=2}{\ifx\bla#4\bla\xintifboolexpr{#3>0}{\xintifboolexpr{#2=1}{}{(\num{#2}}\useKV[ClesDistributivite]{Lettre}\xintifboolexpr{#2=1}{}{)}^2+2\times\xintifboolexpr{#2=1}{}{\num{#2}}\useKV[ClesDistributivite]{Lettre}\times\num{#3}+\num{#3}^2}{\xintifboolexpr{#2=1}{}{(\num{#2}}\useKV[ClesDistributivite]{Lettre}\xintifboolexpr{#2=1}{}{)}^2-2\times\xintifboolexpr{#2=1}{}{\num{#2}}\useKV[ClesDistributivite]{Lettre}\times\num{\fpeval{0-#3}}+\num{\fpeval{0-#3}}^2}\else\xintifboolexpr{#2=1}{}{(\num{#2}}\useKV[ClesDistributivite]{Lettre}\xintifboolexpr{#2=1}{}{)}^2-\num{#3}^2\fi}{} - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=3}{% - \xintifboolexpr{\theNbCalculDistri>1}{\setcounter{NbCalculDistri}{0}}{}% - \stepcounter{NbCalculDistri}% - \ifx\bla#4\bla% - \xdef\Multi{\fpeval{#2*#2}}% - \xdef\Multij{\fpeval{#2*#3}}% - \xdef\Multik{\fpeval{#3*#2}}% - \xdef\Multil{\fpeval{#3*#3}}% - %% ils sont red\'efinis pour pouvoir envisager la somme de deux - %% expressions \`a d\'evelopper - \xdef\Multim{\fpeval{#2*#3+#3*#2}}% - \ifboolKV[ClesDistributivite]{Oppose}{% - \xdef\Multi{\fpeval{-\Multi}}% - \xdef\Multim{\fpeval{-\Multim}}% - \xdef\Multil{\fpeval{-\Multil}}% - \xintifboolexpr{\Multi=0}{}{\xintifboolexpr{\Multi<0}{(}{}\Affichage{\Multi}{0}{0}\xintifboolexpr{\Multi<0}{)}{}}% - \xintifboolexpr{\Multim=0}{}{\xintifboolexpr{\Multim>0}{+}{+(}\Affichage{0}{\Multim}{0}\xintifboolexpr{\Multim<0}{)}{}}% - \xintifboolexpr{\Multil=0}{}{\xintifboolexpr{\Multil>0}{+}{+(}\Affichage{0}{0}{\Multil}\xintifboolexpr{\Multil<0}{)}{}}% - }{% - \Affichage{\Multi}{\Multim}{\Multil}% - } - \ifboolKV[ClesDistributivite]{Somme}{\xdef\SommeA{\fpeval{\SommeA+#2*#2}}\xdef\SommeB{\fpeval{\SommeB+#2*#3+#3*#2}}\xdef\SommeC{\fpeval{\SommeC+#3*#3}}}{}% - \ifboolKV[ClesDistributivite]{Difference}{\xdef\SommeA{\fpeval{\SommeA-#2*#2}}\xdef\SommeB{\fpeval{\SommeB-#2*#3-#3*#2}}\xdef\SommeC{\fpeval{\SommeC-#3*#3}}}{}% - \else% - \xdef\Multi{\fpeval{#2*#4}}% - \xdef\Multij{\fpeval{#2*#5}}% - \xdef\Multik{\fpeval{#3*#4}}% - \xdef\Multil{\fpeval{#3*#5}}% - %% ils sont red\'efinis pour pouvoir envisager la somme de deux - %% expressions \`a d\'evelopper - \xdef\Multim{\fpeval{#2*#5+#3*#4}}% - \ifboolKV[ClesDistributivite]{Oppose}{% - \xdef\Multi{\fpeval{-\Multi}}% - \xdef\Multim{\fpeval{-\Multim}}% - \xdef\Multil{\fpeval{-\Multil}}% - \xintifboolexpr{\Multi=0}{}{\xintifboolexpr{\Multi<0}{(}{}\Affichage{\Multi}{0}{0}\xintifboolexpr{\Multi<0}{)}{}}% - \xintifboolexpr{\Multim=0}{}{\xintifboolexpr{\Multim>0}{+}{+(}\Affichage{0}{\Multim}{0}\xintifboolexpr{\Multim<0}{)}{}}% - \xintifboolexpr{\Multil=0}{}{\xintifboolexpr{\Multil>0}{+}{+(}\Affichage{0}{0}{\Multil}\xintifboolexpr{\Multil<0}{)}{}}% - }{% - \Affichage{\Multi}{\Multim}{\Multil}% - } - \ifboolKV[ClesDistributivite]{Somme}{\xdef\SommeA{\fpeval{\SommeA+#2*#4}}\xdef\SommeB{\fpeval{\SommeB+#2*#5+#3*#4}}\xdef\SommeC{\fpeval{\SommeC+#3*#5}}}{}% - \ifboolKV[ClesDistributivite]{Difference}{\xdef\SommeA{\fpeval{\SommeA-#2*#4}}\xdef\SommeB{\fpeval{\SommeB-#2*#5-#3*#4}}\xdef\SommeC{\fpeval{\SommeC-#3*#5}}}{}% - \fi% - }{}% + \useKVdefault[ClesDistributivite]%obligatoire car la macro n'est pas dans un groupe. + \setKV[ClesDistributivite]{#1}%On lit les arguments optionnels + \ifboolKV[ClesDistributivite]{RAZ}{\xdef\SommeA{0}\xdef\SommeB{0}\xdef\SommeC{0}% + \setcounter{NbCalculDistri}{0}% + }{}% + \colorlet{DCAide}{\useKV[ClesDistributivite]{CouleurAide}}% + \colorlet{DCReduction}{\useKV[ClesDistributivite]{CouleurReduction}}% + \colorlet{DCFlechesh}{\useKV[ClesDistributivite]{CouleurFH}}% + \colorlet{DCFlechesb}{\useKV[ClesDistributivite]{CouleurFB}}% + \ifboolKV[ClesDistributivite]{Tuile}{% + \Tuile{#2}{#3}{#4}{#5}% + }{% + \ensuremath{% + \xintifboolexpr{\useKV[ClesDistributivite]{Echange}>0}{% + \DistriEchange[#1]{#2}{#3}{#4}{#5}% }{% - \ifboolKV[ClesDistributivite]{Numerique}{% - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=0}{% - \num{\fpeval{#2+#3}}\times\num{\fpeval{#4+#5}}\multido{\i=2+1}{4}{=\Distri[Numerique,Etape=\i]{#2}{#3}{#4}{#5}}% - }{% - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=-1}{% - \Distri[Numerique,Etape=3]{#2}{#3}{#4}{#5}\multido{\i=2+-1}{2}{=\Distri[Numerique,Etape=\i]{#2}{#3}{#4}{#5}}=\num{\fpeval{(#2+#3)*(#4+#5)}}% + \ifboolKV[ClesDistributivite]{Remarquable}{% + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=1}{% + \ifx\bla#4\bla(\Affichage{0}{#2}{#3})^2\else(\Affichage{0}{#2}{#3})(\Affichage{0}{#4}{#5})\fi% + }{} + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=2}{\ifx\bla#4\bla\xintifboolexpr{#3>0}{\xintifboolexpr{#2=1}{}{(\num{#2}}\useKV[ClesDistributivite]{Lettre}\xintifboolexpr{#2=1}{}{)}^2+2\times\xintifboolexpr{#2=1}{}{\num{#2}}\useKV[ClesDistributivite]{Lettre}\times\num{#3}+\num{#3}^2}{\xintifboolexpr{#2=1}{}{(\num{#2}}\useKV[ClesDistributivite]{Lettre}\xintifboolexpr{#2=1}{}{)}^2-2\times\xintifboolexpr{#2=1}{}{\num{#2}}\useKV[ClesDistributivite]{Lettre}\times\num{\fpeval{0-#3}}+\num{\fpeval{0-#3}}^2}\else\xintifboolexpr{#2=1}{}{(\num{#2}}\useKV[ClesDistributivite]{Lettre}\xintifboolexpr{#2=1}{}{)}^2-\num{#3}^2\fi}{} + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=3}{% + \xintifboolexpr{\theNbCalculDistri>1}{\setcounter{NbCalculDistri}{0}}{}% + \stepcounter{NbCalculDistri}% + \ifx\bla#4\bla% + \xdef\Multi{\fpeval{#2*#2}}% + \xdef\Multij{\fpeval{#2*#3}}% + \xdef\Multik{\fpeval{#3*#2}}% + \xdef\Multil{\fpeval{#3*#3}}% + %% ils sont red\'efinis pour pouvoir envisager la somme de deux + %% expressions \`a d\'evelopper + \xdef\Multim{\fpeval{#2*#3+#3*#2}}% + \ifboolKV[ClesDistributivite]{Oppose}{% + \xdef\Multi{\fpeval{-\Multi}}% + \xdef\Multim{\fpeval{-\Multim}}% + \xdef\Multil{\fpeval{-\Multil}}% + \xintifboolexpr{\Multi=0}{}{\xintifboolexpr{\Multi<0}{(}{}\Affichage{\Multi}{0}{0}\xintifboolexpr{\Multi<0}{)}{}}% + \xintifboolexpr{\Multim=0}{}{\xintifboolexpr{\Multim>0}{+}{+(}\Affichage{0}{\Multim}{0}\xintifboolexpr{\Multim<0}{)}{}}% + \xintifboolexpr{\Multil=0}{}{\xintifboolexpr{\Multil>0}{+}{+(}\Affichage{0}{0}{\Multil}\xintifboolexpr{\Multil<0}{)}{}}% }{% - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=1}{\num{\fpeval{#2+#3}}\times\num{\fpeval{#4+#5}}}{}% - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=2}{\num{\fpeval{#2+#3}}\times(\num{#4}\xintifboolexpr{#5>0}{+}{-}\num{\fpeval{abs(#5)}})}{}% - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=3}{\num{#3}\times\num{#4}\xintifboolexpr{#5>0}{+}{-}\num{#3}\times\num{\fpeval{abs(#5)}}}{}% - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=4}{\num{\fpeval{#3*#4}}\xintifboolexpr{#5>0}{+}{-}\num{\fpeval{abs(#3*#5)}}}{}% - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=5}{\num{\fpeval{#3*#4+#3*#5}}}{}% - }% - }% + \Affichage{\Multi}{\Multim}{\Multil}% + } + \ifboolKV[ClesDistributivite]{Somme}{\xdef\SommeA{\fpeval{\SommeA+#2*#2}}\xdef\SommeB{\fpeval{\SommeB+#2*#3+#3*#2}}\xdef\SommeC{\fpeval{\SommeC+#3*#3}}}{}% + \ifboolKV[ClesDistributivite]{Difference}{\xdef\SommeA{\fpeval{\SommeA-#2*#2}}\xdef\SommeB{\fpeval{\SommeB-#2*#3-#3*#2}}\xdef\SommeC{\fpeval{\SommeC-#3*#3}}}{}% + \else% + \xdef\Multi{\fpeval{#2*#4}}% + \xdef\Multij{\fpeval{#2*#5}}% + \xdef\Multik{\fpeval{#3*#4}}% + \xdef\Multil{\fpeval{#3*#5}}% + %% ils sont red\'efinis pour pouvoir envisager la somme de deux + %% expressions \`a d\'evelopper + \xdef\Multim{\fpeval{#2*#5+#3*#4}}% + \ifboolKV[ClesDistributivite]{Oppose}{% + \xdef\Multi{\fpeval{-\Multi}}% + \xdef\Multim{\fpeval{-\Multim}}% + \xdef\Multil{\fpeval{-\Multil}}% + \xintifboolexpr{\Multi=0}{}{\xintifboolexpr{\Multi<0}{(}{}\Affichage{\Multi}{0}{0}\xintifboolexpr{\Multi<0}{)}{}}% + \xintifboolexpr{\Multim=0}{}{\xintifboolexpr{\Multim>0}{+}{+(}\Affichage{0}{\Multim}{0}\xintifboolexpr{\Multim<0}{)}{}}% + \xintifboolexpr{\Multil=0}{}{\xintifboolexpr{\Multil>0}{+}{+(}\Affichage{0}{0}{\Multil}\xintifboolexpr{\Multil<0}{)}{}}% + }{% + \Affichage{\Multi}{\Multim}{\Multil}% + } + \ifboolKV[ClesDistributivite]{Somme}{\xdef\SommeA{\fpeval{\SommeA+#2*#4}}\xdef\SommeB{\fpeval{\SommeB+#2*#5+#3*#4}}\xdef\SommeC{\fpeval{\SommeC+#3*#5}}}{}% + \ifboolKV[ClesDistributivite]{Difference}{\xdef\SommeA{\fpeval{\SommeA-#2*#4}}\xdef\SommeB{\fpeval{\SommeB-#2*#5-#3*#4}}\xdef\SommeC{\fpeval{\SommeC-#3*#5}}}{}% + \fi% + }{}% }{% - \ifboolKV[ClesDistributivite]{All}{% - \xdef\NomLettre{\useKV[ClesDistributivite]{NomExpression}}% - \xdef\NomFin{\useKV[ClesDistributivite]{Fin}}% - \xintFor* ##1 in {\xintSeq {1}{\useKV[ClesDistributivite]{Fin}-1}}\do - {\NomLettre&=\Distri[Etape=##1]{#2}{#3}{#4}{#5}\\}% - \NomLettre&=\Distri[Etape=\NomFin]{#2}{#3}{#4}{#5}% + \ifboolKV[ClesDistributivite]{Numerique}{% + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=0}{% + \num{\fpeval{#2+#3}}\times\num{\fpeval{#4+#5}}\multido{\i=2+1}{4}{=\Distri[Numerique,Etape=\i]{#2}{#3}{#4}{#5}}% + }{% + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=-1}{% + \Distri[Numerique,Etape=3]{#2}{#3}{#4}{#5}\multido{\i=2+-1}{2}{=\Distri[Numerique,Etape=\i]{#2}{#3}{#4}{#5}}=\num{\fpeval{(#2+#3)*(#4+#5)}}% + }{% + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=1}{\num{\fpeval{#2+#3}}\times\num{\fpeval{#4+#5}}}{}% + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=2}{\num{\fpeval{#2+#3}}\times(\num{#4}\xintifboolexpr{#5>0}{+}{-}\num{\fpeval{abs(#5)}})}{}% + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=3}{\num{#3}\times\num{#4}\xintifboolexpr{#5>0}{+}{-}\num{#3}\times\num{\fpeval{abs(#5)}}}{}% + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=4}{\num{\fpeval{#3*#4}}\xintifboolexpr{#5>0}{+}{-}\num{\fpeval{abs(#3*#5)}}}{}% + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=5}{\num{\fpeval{#3*#4+#3*#5}}}{}% + }% + }% }{% - % Etape 1 - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=1}{% - \xintifboolexpr{#2=0}{% - }{\xintifboolexpr{#3=0}{}{(}}\Tikzmark{\Affichage[#1]{0}{#2}{0}}% - \ifboolKV[ClesDistributivite]{AideAdda}{\mathcolor{DCAide}{+(}}{}% - \xintifboolexpr{#3>0}{\xintifboolexpr{#2=0}{}{+}}{\xintifboolexpr{#3<0}{-}{}}\Tikzmark{\Affichage[#1]{0}{0}{\fpeval{abs(#3)}}}% - \ifboolKV[ClesDistributivite]{AideAdda}{\mathcolor{DCAide}{)}}{}% - \xintifboolexpr{#2=0}{}{\xintifboolexpr{#3=0}{}{)}}% - % - \ifboolKV[ClesDistributivite]{AideMul}{\times}{}%on aide dans le cas double - \xdef\Multi{\fpeval{#4*#5}}%affichage auto si (a+b)xk - % - \xintifboolexpr{\Multi=0}{\times% - \xintifboolexpr{#4<0}{(}{\xintifboolexpr{#5<0}{(}{}}}{(}% - \Tikzmark{\Affichage[#1]{0}{#4}{0}}% - \ifboolKV[ClesDistributivite]{AideAddb}{\mathcolor{DCAide}{+(}}{}% - \xintifboolexpr{#5>0}{\xintifboolexpr{#4=0}{}{+}}{\xintifboolexpr{#5<0}{\xintifboolexpr{#4=0}{{-}}{-}}{}}\Tikzmark{\Affichage[#1]{0}{0}{\fpeval{abs(#5)}}}% - \ifboolKV[ClesDistributivite]{AideAddb}{\mathcolor{DCAide}{)}}{}% - \xintifboolexpr{\Multi=0}{% - \xintifboolexpr{#4<0}{)}{\xintifboolexpr{#5<0}{)}{}}}{)}% - \ifboolKV[ClesDistributivite]{Fleches}{% - \xdef\Multi{\fpeval{#2*#3*#4*#5}}% + \ifboolKV[ClesDistributivite]{All}{% + \xdef\NomLettre{\useKV[ClesDistributivite]{NomExpression}}% + \xdef\NomFin{\useKV[ClesDistributivite]{Fin}}% + \xintFor* ##1 in {\xintSeq {1}{\useKV[ClesDistributivite]{Fin}-1}}\do + {\NomLettre&=\Distri[Etape=##1]{#2}{#3}{#4}{#5}\\}% + \NomLettre&=\Distri[Etape=\NomFin]{#2}{#3}{#4}{#5}% + }{% + % Etape 1 + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=1}{% + \xintifboolexpr{#2=0}{% + }{\xintifboolexpr{#3=0}{}{(}}\Tikzmark{\Affichage[#1]{0}{#2}{0}}% + \ifboolKV[ClesDistributivite]{AideAdda}{\mathcolor{DCAide}{+(}}{}% + \xintifboolexpr{#3>0}{\xintifboolexpr{#2=0}{}{+}}{\xintifboolexpr{#3<0}{-}{}}\Tikzmark{\Affichage[#1]{0}{0}{\fpeval{abs(#3)}}}% + \ifboolKV[ClesDistributivite]{AideAdda}{\mathcolor{DCAide}{)}}{}% + \xintifboolexpr{#2=0}{}{\xintifboolexpr{#3=0}{}{)}}% + % + \ifboolKV[ClesDistributivite]{AideMul}{\times}{}%on aide dans le cas double + \xdef\Multi{\fpeval{#4*#5}}%affichage auto si (a+b)xk + % + \xintifboolexpr{\Multi=0}{\times% + \xintifboolexpr{#4<0}{(}{\xintifboolexpr{#5<0}{(}{}}}{(}% + \Tikzmark{\Affichage[#1]{0}{#4}{0}}% + \ifboolKV[ClesDistributivite]{AideAddb}{\mathcolor{DCAide}{+(}}{}% + \xintifboolexpr{#5>0}{\xintifboolexpr{#4=0}{}{+}}{\xintifboolexpr{#5<0}{\xintifboolexpr{#4=0}{{-}}{-}}{}}\Tikzmark{\Affichage[#1]{0}{0}{\fpeval{abs(#5)}}}% + \ifboolKV[ClesDistributivite]{AideAddb}{\mathcolor{DCAide}{)}}{}% \xintifboolexpr{\Multi=0}{% - \xdef\Multij{\fpeval{#2*#3}}%\relax - \xintifboolexpr{\Multij=0}{\xintifboolexpr{#2=0}{\DrawArrowSimple{1}}{\DrawArrowSimple{0}}}{\xintifboolexpr{#4=0}{\DrawArrowSimpleRenverse{3}}{\DrawArrowSimpleRenverse{2}}}% - }{% - \DrawArrow% + \xintifboolexpr{#4<0}{)}{\xintifboolexpr{#5<0}{)}{}}}{)}% + \ifboolKV[ClesDistributivite]{Fleches}{% + \xdef\Multi{\fpeval{#2*#3*#4*#5}}% + \xintifboolexpr{\Multi=0}{% + \xdef\Multij{\fpeval{#2*#3}}%\relax + \xintifboolexpr{\Multij=0}{\xintifboolexpr{#2=0}{\DrawArrowSimple{1}}{\DrawArrowSimple{0}}}{\xintifboolexpr{#4=0}{\DrawArrowSimpleRenverse{3}}{\DrawArrowSimpleRenverse{2}}}% + }{% + \DrawArrow% + }% + }{}\setcounter{NbDistri}{0}% + }{} + % Etape 2 + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=2}{% + \xdef\Multi{\fpeval{#2*#4}}% + \xintifboolexpr{\Multi=0}{}{% + \xintifboolexpr{#2<0}{(}{}\Affichage[#1]{0}{#2}{0}\xintifboolexpr{#2<0}{)}{}\times\xintifboolexpr{#4<0}{(}{}\Affichage[#1]{0}{#4}{0}\xintifboolexpr{#4<0}{)}{}% + } + \xdef\Multij{\fpeval{#2*#5}}% + \xintifboolexpr{\Multij=0}{}{% + \xintifboolexpr{\Multi=0}{}{+}% + \xintifboolexpr{#2<0}{(}{}\Affichage[#1]{0}{#2}{0}\xintifboolexpr{#2<0}{)}{}\times\xintifboolexpr{#5<0}{(}{}\Affichage[#1]{0}{0}{#5}\xintifboolexpr{#5<0}{)}{}% }% - }{}\setcounter{NbDistri}{0}% - }{} - % Etape 2 - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=2}{% - \xdef\Multi{\fpeval{#2*#4}}% - \xintifboolexpr{\Multi=0}{}{% - \xintifboolexpr{#2<0}{(}{}\Affichage[#1]{0}{#2}{0}\xintifboolexpr{#2<0}{)}{}\times\xintifboolexpr{#4<0}{(}{}\Affichage[#1]{0}{#4}{0}\xintifboolexpr{#4<0}{)}{}% - } - \xdef\Multij{\fpeval{#2*#5}}% - \xintifboolexpr{\Multij=0}{}{% - \xintifboolexpr{\Multi=0}{}{+}% - \xintifboolexpr{#2<0}{(}{}\Affichage[#1]{0}{#2}{0}\xintifboolexpr{#2<0}{)}{}\times\xintifboolexpr{#5<0}{(}{}\Affichage[#1]{0}{0}{#5}\xintifboolexpr{#5<0}{)}{}% - }% - \xdef\Multik{\fpeval{#3*#4}}% - \xintifboolexpr{\Multik=0}{}{% - \xintifboolexpr{\Multi=0}{}{+}% - \xintifboolexpr{#3<0}{(}{}\Affichage[#1]{0}{0}{#3}\xintifboolexpr{#3<0}{)}{}\times\xintifboolexpr{#4<0}{(}{}\Affichage[#1]{0}{#4}{0}\xintifboolexpr{#4<0}{)}{}% - }% - \xdef\Multil{\fpeval{#3*#5}}% - \xintifboolexpr{\Multil=0}{}{+% - \xintifboolexpr{#3<0}{(}{}\Affichage[#1]{0}{0}{#3}\xintifboolexpr{#3<0}{)}{}\times\xintifboolexpr{#5<0}{(}{}\Affichage[#1]{0}{0}{#5}\xintifboolexpr{#5<0}{)}{}% - }% - }{}% - % Etape 3 - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=3}{% - \stepcounter{NbCalculDistri}% - \xdef\Multi{\fpeval{#2*#4}}% - \xdef\Multij{\fpeval{#2*#5}}% - \xdef\Multik{\fpeval{#3*#4}}% - \xdef\Multil{\fpeval{#3*#5}}% - %% ils sont red\'efinis pour pouvoir envisager la somme de deux - %% expressions \`a d\'evelopper - \xintifboolexpr{\theNbCalculDistri>1}{\xintifboolexpr{\Multi<0}{(\Affichage{\Multi}{0}{0})}{\Affichage{\Multi}{0}{0}}}{\Affichage{\Multi}{0}{0}}% - \ifboolKV[ClesDistributivite]{Reduction}{\mathunderline{DCReduction}{% - \xintifboolexpr{\Multij=0}{}{\xintifboolexpr{\Multi=0}{}{{}+}\xintifboolexpr{\Multij<0}{(}{}\Affichage{0}{\Multij}{0}\xintifboolexpr{\Multij<0}{)}{}}% - \xintifboolexpr{\Multik=0}{}{\xintifboolexpr{\Multil=0}{\xintifboolexpr{#2=0}{}{+}}{+}\xintifboolexpr{\Multik<0}{(}{}\Affichage{0}{\Multik}{0}\xintifboolexpr{\Multik<0}{)}{}}% + \xdef\Multik{\fpeval{#3*#4}}% + \xintifboolexpr{\Multik=0}{}{% + \xintifboolexpr{\Multi=0}{}{+}% + \xintifboolexpr{#3<0}{(}{}\Affichage[#1]{0}{0}{#3}\xintifboolexpr{#3<0}{)}{}\times\xintifboolexpr{#4<0}{(}{}\Affichage[#1]{0}{#4}{0}\xintifboolexpr{#4<0}{)}{}% }% - }{% - \xintifboolexpr{\Multij=0}{}{\xintifboolexpr{\Multi=0}{}{+}\xintifboolexpr{\Multij<0}{(}{}\Affichage{0}{\Multij}{0}\xintifboolexpr{\Multij<0}{)}{}}% - \xintifboolexpr{\Multik=0}{}{\xintifboolexpr{\Multil=0}{\xintifboolexpr{#2=0}{}{+}}{\xintifboolexpr{#2=0}{}{+}}\xintifboolexpr{\Multik<0}{(}{}\Affichage{0}{\Multik}{0}\xintifboolexpr{\Multik<0}{)}{}}% - }% - \xintifboolexpr{\Multil=0}{}{+}\xintifboolexpr{\Multil<0}{(}{}\Affichage{0}{0}{\Multil}\xintifboolexpr{\Multil<0}{)}{}% - }{}% - % Etape 4 - \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=4}{% - \xdef\Multi{\fpeval{#2*#4}}% - \xdef\Multij{\fpeval{#2*#5}}% - \xdef\Multik{\fpeval{#3*#4}}% - \xdef\Multil{\fpeval{#3*#5}}% - %% ils sont red\'efinis pour pouvoir envisager la somme de deux - %% expressions \`a d\'evelopper - \xdef\Multim{\fpeval{#2*#5+#3*#4}}% - \xintifboolexpr{\theNbCalculDistri>1}{\setcounter{NbCalculDistri}{0}}{}% - \stepcounter{NbCalculDistri}% - \ifboolKV[ClesDistributivite]{Oppose}{% - \xdef\Multi{\fpeval{-\Multi}}% - \xdef\Multim{\fpeval{-\Multim}}% - \xdef\Multil{\fpeval{-\Multil}}% - \xintifboolexpr{\Multi=0}{}{\xintifboolexpr{\Multi<0}{(}{}\Affichage{\Multi}{0}{0}\xintifboolexpr{\Multi<0}{)}{}}% - \xintifboolexpr{\Multim=0}{}{\xintifboolexpr{\Multim>0}{+}{+(}\Affichage{0}{\Multim}{0}\xintifboolexpr{\Multim<0}{)}{}}% - \xintifboolexpr{\Multil=0}{}{\xintifboolexpr{\Multil>0}{+}{+(}\Affichage{0}{0}{\Multil}\xintifboolexpr{\Multil<0}{)}{}}% - }{% + \xdef\Multil{\fpeval{#3*#5}}% + \xintifboolexpr{\Multil=0}{}{+% + \xintifboolexpr{#3<0}{(}{}\Affichage[#1]{0}{0}{#3}\xintifboolexpr{#3<0}{)}{}\times\xintifboolexpr{#5<0}{(}{}\Affichage[#1]{0}{0}{#5}\xintifboolexpr{#5<0}{)}{}% + }% + }{}% + % Etape 3 + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=3}{% + \stepcounter{NbCalculDistri}% + \xdef\Multi{\fpeval{#2*#4}}% + \xdef\Multij{\fpeval{#2*#5}}% + \xdef\Multik{\fpeval{#3*#4}}% + \xdef\Multil{\fpeval{#3*#5}}% + %% ils sont red\'efinis pour pouvoir envisager la somme de deux + %% expressions \`a d\'evelopper \xintifboolexpr{\theNbCalculDistri>1}{\xintifboolexpr{\Multi<0}{(\Affichage{\Multi}{0}{0})}{\Affichage{\Multi}{0}{0}}}{\Affichage{\Multi}{0}{0}}% - \xintifboolexpr{\Multim=0}{}{% - \xintifboolexpr{\Multim>0}{+\Affichage{0}{\Multim}{0}}{-\Affichage{0}{\fpeval{-\Multim}}{0}}% + \ifboolKV[ClesDistributivite]{Reduction}{\mathunderline{DCReduction}{% + \xintifboolexpr{\Multij=0}{}{\xintifboolexpr{\Multi=0}{}{{}+}\xintifboolexpr{\Multij<0}{(}{}\Affichage{0}{\Multij}{0}\xintifboolexpr{\Multij<0}{)}{}}% + \xintifboolexpr{\Multik=0}{}{\xintifboolexpr{\Multil=0}{\xintifboolexpr{#2=0}{}{+}}{+}\xintifboolexpr{\Multik<0}{(}{}\Affichage{0}{\Multik}{0}\xintifboolexpr{\Multik<0}{)}{}}% + }% + }{% + \xintifboolexpr{\Multij=0}{}{\xintifboolexpr{\Multi=0}{}{+}\xintifboolexpr{\Multij<0}{(}{}\Affichage{0}{\Multij}{0}\xintifboolexpr{\Multij<0}{)}{}}% + \xintifboolexpr{\Multik=0}{}{\xintifboolexpr{\Multil=0}{\xintifboolexpr{#2=0}{}{+}}{\xintifboolexpr{#2=0}{}{+}}\xintifboolexpr{\Multik<0}{(}{}\Affichage{0}{\Multik}{0}\xintifboolexpr{\Multik<0}{)}{}}% }% - \xintifboolexpr{\Multil=0}{}{\xintifboolexpr{\Multil<0}{-\Affichage{0}{0}{\fpeval{-\Multil}}}{+\Affichage{0}{0}{\Multil}}}% - } - \ifboolKV[ClesDistributivite]{Somme}{\xdef\SommeA{\fpeval{\SommeA+#2*#4}}\xdef\SommeB{\fpeval{\SommeB+#2*#5+#3*#4}}\xdef\SommeC{\fpeval{\SommeC+#3*#5}}}{}% - \ifboolKV[ClesDistributivite]{Difference}{\xdef\SommeA{\fpeval{\SommeA-#2*#4}}\xdef\SommeB{\fpeval{\SommeB-#2*#5-#3*#4}}\xdef\SommeC{\fpeval{\SommeC-#3*#5}}}{}% - }{}% + \xintifboolexpr{\Multil=0}{}{+}\xintifboolexpr{\Multil<0}{(}{}\Affichage{0}{0}{\Multil}\xintifboolexpr{\Multil<0}{)}{}% + }{}% + % Etape 4 + \xintifboolexpr{\useKV[ClesDistributivite]{Etape}=4}{% + \xdef\Multi{\fpeval{#2*#4}}% + \xdef\Multij{\fpeval{#2*#5}}% + \xdef\Multik{\fpeval{#3*#4}}% + \xdef\Multil{\fpeval{#3*#5}}% + %% ils sont red\'efinis pour pouvoir envisager la somme de deux + %% expressions \`a d\'evelopper + \xdef\Multim{\fpeval{#2*#5+#3*#4}}% + \xintifboolexpr{\theNbCalculDistri>1}{\setcounter{NbCalculDistri}{0}}{}% + \stepcounter{NbCalculDistri}% + \ifboolKV[ClesDistributivite]{Oppose}{% + \xdef\Multi{\fpeval{-\Multi}}% + \xdef\Multim{\fpeval{-\Multim}}% + \xdef\Multil{\fpeval{-\Multil}}% + \xintifboolexpr{\Multi=0}{}{\xintifboolexpr{\Multi<0}{(}{}\Affichage{\Multi}{0}{0}\xintifboolexpr{\Multi<0}{)}{}}% + \xintifboolexpr{\Multim=0}{}{\xintifboolexpr{\Multim>0}{+}{+(}\Affichage{0}{\Multim}{0}\xintifboolexpr{\Multim<0}{)}{}}% + \xintifboolexpr{\Multil=0}{}{\xintifboolexpr{\Multil>0}{+}{+(}\Affichage{0}{0}{\Multil}\xintifboolexpr{\Multil<0}{)}{}}% + }{% + \xintifboolexpr{\theNbCalculDistri>1}{\xintifboolexpr{\Multi<0}{(\Affichage{\Multi}{0}{0})}{\Affichage{\Multi}{0}{0}}}{\Affichage{\Multi}{0}{0}}% + \xintifboolexpr{\Multim=0}{}{% + \xintifboolexpr{\Multim>0}{+\Affichage{0}{\Multim}{0}}{-\Affichage{0}{\fpeval{-\Multim}}{0}}% + }% + \xintifboolexpr{\Multil=0}{}{\xintifboolexpr{\Multil<0}{-\Affichage{0}{0}{\fpeval{-\Multil}}}{+\Affichage{0}{0}{\Multil}}}% + } + \ifboolKV[ClesDistributivite]{Somme}{\xdef\SommeA{\fpeval{\SommeA+#2*#4}}\xdef\SommeB{\fpeval{\SommeB+#2*#5+#3*#4}}\xdef\SommeC{\fpeval{\SommeC+#3*#5}}}{}% + \ifboolKV[ClesDistributivite]{Difference}{\xdef\SommeA{\fpeval{\SommeA-#2*#4}}\xdef\SommeB{\fpeval{\SommeB-#2*#5-#3*#4}}\xdef\SommeC{\fpeval{\SommeC-#3*#5}}}{}% + }{}% + }% }% }% }% @@ -5948,53 +6625,55 @@ vardef Positions(expr Step)= }% \ifboolKV[ClesTrigo]{Cosinus}{% \ifx\bla#3\bla%on calcule le c\^ot\'e adjacent - \xdef\ResultatTrigo{\fpeval{round(\fpeval{#4*cosd(#5)},\useKV[ClesTrigo]{Precision})}}% + \xdef\ResultatTrigo{\fpeval{round(#4*cosd(#5),\useKV[ClesTrigo]{Precision})}}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomC\times\cos(\widehat{\NomB\NomA\NomC})&=\NomA\NomB\\ \num{#4}\times\cos(\ang{#5})&=\NomA\NomB\\ - \num{\fpeval{round(\fpeval{#4*cosd(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(\fpeval{#4*cosd(#5)},2)}}{=}{\approx}\NomA\NomB% + \num{\fpeval{round(#4*cosd(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(#4*cosd(#5),9)}}{=}{\approx}\NomA\NomB% \end{align*}% }{% \begin{align*} \cos(\widehat{\NomB\NomA\NomC})&=\frac{\NomA\NomB}{\NomA\NomC}\\ \cos(\ang{#5})&=\frac{\NomA\NomB}{\num{#4}}\\ \num{#4}\times\cos(\ang{#5})&=\NomA\NomB\\ - \num{\fpeval{round(\fpeval{#4*cosd(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(\fpeval{#4*cosd(#5)},2)}}{=}{\approx}\NomA\NomB + \num{\fpeval{round(#4*cosd(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(#4*cosd(#5),9)}}{=}{\approx}\NomA\NomB \end{align*} }% \else% \ifx\bla#4\bla%on calcule l'hypoth\'enuse - \xdef\ResultatTrigo{\fpeval{round(\fpeval{#3/cosd(#5)},\useKV[ClesTrigo]{Precision})}}% + \xdef\ResultatTrigo{\fpeval{round(#3/cosd(#5),\useKV[ClesTrigo]{Precision})}}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomC\times\cos(\widehat{\NomB\NomA\NomC})&=\NomA\NomB\\ \NomA\NomC\times\cos(\ang{#5})&=\num{#3}\\ \NomA\NomC&=\frac{\num{#3}}{\cos(\ang{#5})}\\ - \NomA\NomC&\IfInteger{\fpeval{round(\fpeval{#3/cosd(#5)},2)}}{=}{\approx}\num{\fpeval{round(\fpeval{#3/cosd(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% + \NomA\NomC&\IfInteger{\fpeval{round(#3/cosd(#5),9)}}{=}{\approx}\num{\fpeval{round(#3/cosd(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% \end{align*} }{% \begin{align*} \cos(\widehat{\NomB\NomA\NomC})&=\frac{\NomA\NomB}{\NomA\NomC}\\ \cos(\ang{#5})&=\frac{\num{#3}}{\NomA\NomC}\\ \NomA\NomC&=\frac{\num{#3}}{\cos(\ang{#5})}\\ - \NomA\NomC&\IfInteger{\fpeval{round(\fpeval{#3/cosd(#5)},2)}}{=}{\approx}\num{\fpeval{round(\fpeval{#3/cosd(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% + \NomA\NomC&\IfInteger{\fpeval{round(#3/cosd(#5),9)}}{=}{\approx}\num{\fpeval{round(#3/cosd(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% \end{align*}% }% \else%on calcule l'angle - \xdef\ResultatTrigo{\fpeval{round(\fpeval{acosd(#3/#4)})}}% + \xdef\ResultatTrigo{\fpeval{round(acosd(#3/#4),\useKV[ClesTrigo]{Precision})}}% + \setKV[ClesTrigo]{Precision=0}% + \setKV[ClesTrigo]{#1}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomC\times\cos(\widehat{\NomB\NomA\NomC})&=\NomA\NomB\\ \num{#4}\times\cos(\widehat{\NomB\NomA\NomC})&=\num{#3}\\ \cos(\widehat{\NomB\NomA\NomC})&=\frac{\num{#3}}{\num{#4}}\\ - \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(\fpeval{acosd(#3/#4)},2)}}{=}{\approx}\ang{\fpeval{round(\fpeval{acosd(#3/#4)})}}% + \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(acosd(#3/#4),9)}}{=}{\approx}\ang{\fpeval{round(acosd(#3/#4),\useKV[ClesTrigo]{Precision})}}% \end{align*}% }{% \begin{align*} \cos(\widehat{\NomB\NomA\NomC})&=\frac{\NomA\NomB}{\NomA\NomC}\\ \cos(\widehat{\NomB\NomA\NomC})&=\frac{\num{#3}}{\num{#4}}\\ - \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(\fpeval{acosd(#3/#4)},2)}}{=}{\approx}\ang{\fpeval{round(\fpeval{acosd(#3/#4)})}}% + \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(acosd(#3/#4),9)}}{=}{\approx}\ang{\fpeval{round(acosd(#3/#4),\useKV[ClesTrigo]{Precision})}}% \end{align*}% }% \fi% @@ -6002,53 +6681,55 @@ vardef Positions(expr Step)= }{}% \ifboolKV[ClesTrigo]{Sinus}{% \ifx\bla#3\bla%on calcule le c\^ot\'e oppos\'e - \xdef\ResultatTrigo{\fpeval{round(\fpeval{#4*sind(#5)},\useKV[ClesTrigo]{Precision})}}% + \xdef\ResultatTrigo{\fpeval{round(#4*sind(#5),\useKV[ClesTrigo]{Precision})}}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomC\times\sin(\widehat{\NomB\NomA\NomC})&=\NomB\NomC\\ \num{#4}\times\sin(\ang{#5})&=\NomB\NomC\\ - \num{\fpeval{round(\fpeval{#4*sind(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(\fpeval{#4*sind(#5)},2)}}{=}{\approx}\NomB\NomC% + \num{\fpeval{round(#4*sind(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(#4*sind(#5),9)}}{=}{\approx}\NomB\NomC% \end{align*}% }{% \begin{align*} \sin(\widehat{\NomB\NomA\NomC})&=\frac{\NomB\NomC}{\NomA\NomC}\\ \sin(\ang{#5})&=\frac{\NomB\NomC}{\num{#4}}\\ \num{#4}\times\sin(\ang{#5})&=\NomB\NomC\\ - \num{\fpeval{round(\fpeval{#4*sind(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(\fpeval{#4*sind(#5)},2)}}{=}{\approx}\NomB\NomC% + \num{\fpeval{round(#4*sind(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(#4*sind(#5),9)}}{=}{\approx}\NomB\NomC% \end{align*}% }% \else \ifx\bla#4\bla%on calcule l'hypoth\'enuse - \xdef\ResultatTrigo{\fpeval{round(\fpeval{#3/sind(#5)},\useKV[ClesTrigo]{Precision})}}% + \xdef\ResultatTrigo{\fpeval{round(#3/sind(#5),\useKV[ClesTrigo]{Precision})}}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomC\times\sin(\widehat{\NomB\NomA\NomC})&=\NomB\NomC\\ \NomA\NomC\times\sin(\ang{#5})&=\num{#3}\\ \NomA\NomC&=\frac{\num{#3}}{\sin(\ang{#5})}\\ - \NomA\NomC&\IfInteger{\fpeval{round(\fpeval{#3/sind(#5)},2)}}{=}{\approx}\num{\fpeval{round(\fpeval{#3/sind(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% + \NomA\NomC&\IfInteger{\fpeval{round(#3/sind(#5),9)}}{=}{\approx}\num{\fpeval{round(#3/sind(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% \end{align*}% }{% \begin{align*} \sin(\widehat{\NomB\NomA\NomC})&=\frac{\NomB\NomC}{\NomA\NomC}\\ \sin(\ang{#5})&=\frac{\num{#3}}{\NomA\NomC}\\ \NomA\NomC&=\frac{\num{#3}}{\sin(\ang{#5})}\\ - \NomA\NomC&\IfInteger{\fpeval{round(\fpeval{#3/sind(#5)},2)}}{=}{\approx}\num{\fpeval{round(\fpeval{#3/sind(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% + \NomA\NomC&\IfInteger{\fpeval{round(#3/sind(#5),9)}}{=}{\approx}\num{\fpeval{round(#3/sind(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% \end{align*}% }% \else%on calcule l'angle - \xdef\ResultatTrigo{\fpeval{round(\fpeval{asind(#3/#4)})}}% + \xdef\ResultatTrigo{\fpeval{round(asind(#3/#4),\useKV[ClesTrigo]{Precision})}}% + \setKV[ClesTrigo]{Precision=0}% + \setKV[ClesTrigo]{#1}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomC\times\sin(\widehat{\NomB\NomA\NomC})&=\NomB\NomC\\ \num{#4}\times\sin(\widehat{\NomB\NomA\NomC})&=\num{#3}\\ \sin(\widehat{\NomB\NomA\NomC})&=\frac{\num{#3}}{\num{#4}}\\ - \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(\fpeval{asind(#3/#4)},2)}}{=}{\approx}\ang{\fpeval{round(\fpeval{asind(#3/#4)})}}% + \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(asind(#3/#4),9)}}{=}{\approx}\ang{\fpeval{round(asind(#3/#4),\useKV[ClesTrigo]{Precision})}}% \end{align*}% }{% \begin{align*} \sin(\widehat{\NomB\NomA\NomC})&=\frac{\NomB\NomC}{\NomA\NomC}\\ \sin(\widehat{\NomB\NomA\NomC})&=\frac{\num{#3}}{\num{#4}}\\ - \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(\fpeval{asind(#3/#4)},2)}}{=}{\approx}\ang{\fpeval{round(\fpeval{asind(#3/#4)})}}% + \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(asind(#3/#4),9)}}{=}{\approx}\ang{\fpeval{round(asind(#3/#4),\useKV[ClesTrigo]{Precision})}}% \end{align*}% }% \fi% @@ -6056,53 +6737,55 @@ vardef Positions(expr Step)= }{}% \ifboolKV[ClesTrigo]{Tangente}{% \ifx\bla#3\bla%on calcule le c\^ot\'e oppos\'e - \xdef\ResultatTrigo{\fpeval{round(\fpeval{#4*tand(#5)},\useKV[ClesTrigo]{Precision})}}% + \xdef\ResultatTrigo{\fpeval{round(#4*tand(#5),\useKV[ClesTrigo]{Precision})}}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomB\times\tan(\widehat{\NomB\NomA\NomC})&=\NomB\NomC\\% \num{#4}\times\tan(\ang{#5})&=\NomB\NomC\\% - \num{\fpeval{round(\fpeval{#4*tand(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(\fpeval{#4*tand(#5)},2)}}{=}{\approx}\NomB\NomC% + \num{\fpeval{round(#4*tand(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(#4*tand(#5),9)}}{=}{\approx}\NomB\NomC% \end{align*}% }{% \begin{align*} \tan(\widehat{\NomB\NomA\NomC})&=\frac{\NomB\NomC}{\NomA\NomB}\\ \tan(\ang{#5})&=\frac{\NomB\NomC}{\num{#4}}\\ \num{#4}\times\tan(\ang{#5})&=\NomB\NomC\\ - \num{\fpeval{round(\fpeval{#4*tand(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(\fpeval{#4*tand(#5)},2)}}{=}{\approx}\NomB\NomC% + \num{\fpeval{round(#4*tand(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}&\IfInteger{\fpeval{round(#4*tand(#5),9)}}{=}{\approx}\NomB\NomC% \end{align*}% }% \else \ifx\bla#4\bla%on calcule l'adjacent - \xdef\ResultatTrigo{\fpeval{round(\fpeval{#3/tand(#5)},\useKV[ClesTrigo]{Precision})}}% + \xdef\ResultatTrigo{\fpeval{round(#3/tand(#5),\useKV[ClesTrigo]{Precision})}}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomB\times\tan(\widehat{\NomB\NomA\NomC})&=\NomB\NomC\\ \NomA\NomB\times\tan(\ang{#5})&=\num{#3}\\ \NomA\NomB&=\frac{\num{#3}}{\tan(\ang{#5})}\\ - \NomA\NomB&\IfInteger{\fpeval{round(\fpeval{#3/tand(#5)},2)}}{=}{\approx}\num{\fpeval{round(\fpeval{#3/tand(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% + \NomA\NomB&\IfInteger{\fpeval{round(#3/tand(#5),9)}}{=}{\approx}\num{\fpeval{round(#3/tand(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% \end{align*}% }{% \begin{align*} \tan(\widehat{\NomB\NomA\NomC})&=\frac{\NomB\NomC}{\NomA\NomB}\\ \tan(\ang{#5})&=\frac{\num{#3}}{\NomA\NomB}\\ \NomA\NomB&=\frac{\num{#3}}{\tan(\ang{#5})}\\ - \NomA\NomB&\IfInteger{\fpeval{round(\fpeval{#3/tand(#5)},2)}}{=}{\approx}\num{\fpeval{round(\fpeval{#3/tand(#5)},\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% + \NomA\NomB&\IfInteger{\fpeval{round(#3/tand(#5),9)}}{=}{\approx}\num{\fpeval{round(#3/tand(#5),\useKV[ClesTrigo]{Precision})}}~\text{\useKV[ClesTrigo]{Unite}}% \end{align*}% }% \else%on calcule l'angle - \xdef\ResultatTrigo{\fpeval{round(\fpeval{atand(#3/#4)})}}% + \setKV[ClesTrigo]{Precision=0}% + \setKV[ClesTrigo]{#1}% + \xdef\ResultatTrigo{\fpeval{round(atand(#3/#4),\useKV[ClesTrigo]{Precision})}}% \ifboolKV[ClesTrigo]{Propor}{% \begin{align*} \NomA\NomB\times\tan(\widehat{\NomB\NomA\NomC})&=\NomB\NomC\\ \num{#4}\times\tan(\widehat{\NomB\NomA\NomC})&=\num{#3}\\ \tan(\widehat{\NomB\NomA\NomC})&=\frac{\num{#3}}{\num{#4}}\\ - \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(\fpeval{atand(#3/#4)},2)}}{=}{\approx}\ang{\fpeval{round(\fpeval{atand(#3/#4)})}}% + \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(atand(#3/#4),9)}}{=}{\approx}\ang{\fpeval{round(atand(#3/#4),\useKV[ClesTrigo]{Precision})}}% \end{align*}% }{% \begin{align*} \tan(\widehat{\NomB\NomA\NomC})&=\frac{\NomB\NomC}{\NomA\NomB}\\ \tan(\widehat{\NomB\NomA\NomC})&=\frac{\num{#3}}{\num{#4}}\\ - \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(\fpeval{atand(#3/#4)},2)}}{=}{\approx}\ang{\fpeval{round(\fpeval{atand(#3/#4)})}}% + \widehat{\NomB\NomA\NomC}&\IfInteger{\fpeval{round(atand(#3/#4),9)}}{=}{\approx}\ang{\fpeval{round(atand(#3/#4),\useKV[ClesTrigo]{Precision})}}% \end{align*}% }% \fi% @@ -6883,7 +7566,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \DTLgnewdb{mtdbEE}% \DTLgnewdb{mtdbEEqual}% -% +% \newcommand\Stat[2][]{% \useKVdefault[ClesStat]% \setKV[ClesStat]{#1}% @@ -6897,89 +7580,89 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl }% \readlist*\ListeComplete{\foo}% \setKV[ClesStat]{Qualitatif}% - }{ - \ifboolKV[ClesStat]{Sondage}{% - \setsepchar{,}\ignoreemptyitems% - \readlist*\Liste{#2}% - % "liste vide" - \newtoks\tabtoksEEa% - \tabtoksEEa{}% - % - % "liste vide" - \newtoks\tabtoksEEb% - \tabtoksEEb{}% - % - \readlist*\ListeSansDoublonsEE{999}% %% Pour ne pas avoir une liste vide - % - \newcount\cmptEE% - \newcount\PasNumEE% %% Permettra de savoir si ce sondage est qualitatif ou quantitatif - \PasNumEE=0\relax% - \DTLcleardb{mtdbEE}% - % on range les resultats du sondage par ordre croissant. - \foreachitem\x\in\Liste{% - \DTLnewrow{mtdbEE}% - \DTLnewdbentry{mtdbEE}{Numeric}{\x}% - }% - \dtlsort{Numeric}{mtdbEE}{\dtlicompare}% - \DTLforeach{mtdbEE}{\nba=Numeric}{% - \IfDecimal{\nba}{}{\PasNumEE=\numexpr\PasNumEE+1\relax}% - \cmptEE=0\relax% - \foreachitem\nbb\in\ListeSansDoublonsEE{% - \ifthenelse{\equal{\nba}{\nbb}}{\cmptEE=\numexpr\cmptEE+1\relax}{}% - }% - \ifthenelse{\equal{\the\cmptEE}{0}}{% - \expandafter\AjoutListEEb\nba\nil% - \xdef\listEEa{\the\tabtoksEEb}% - \ignoreemptyitems% - \setsepchar{,}% - \readlist*\ListeSansDoublonsEE\listEEa% %%% Enl\`eve tous les \'elements - %%% identiques de Liste - }{}% - }% - \foreachitem\nba\in\ListeSansDoublonsEE{% - \cmptEE=0\relax% - \DTLforeach{mtdbEE}{\nbb=Numeric}{% - \ifthenelse{\equal{\nba}{\nbb}}{\cmptEE=\numexpr\cmptEE+1\relax}{}% - }% - \expandafter\AjoutListEEab\nba\nil% - \expandafter\AjoutListEEaa\the\cmptEE\nil% %%% Compte tous les \'elements - %%% identiques de Liste - }% - \xdef\listEEb{\the\tabtoksEEa} - \ignoreemptyitems% - \setsepchar[*]{,*/} - \readlist*\ListeComplete\listEEb% - % - \ifthenelse{\equal{\the\PasNumEE}{0}}{\setKV[ClesStat]{Quantitatif}}{\setKV[ClesStat]{Qualitatif}}% }{% - \ifboolKV[ClesStat]{Qualitatif}{% - % % on lit la liste \'ecrite sous la forme valeur/effectif - \setsepchar[*]{,*/}\ignoreemptyitems% - \readlist*\ListeComplete{#2}% - }{% Dans le qualitatif, on trie d'abord les valeurs. - \setsepchar[*]{,*/}\ignoreemptyitems% - \readlist*\ListeInitiale{#2}% -% "liste vide" + \ifboolKV[ClesStat]{Sondage}{% + \setsepchar{,}\ignoreemptyitems% + \readlist*\Liste{#2}% + % "liste vide" + \newtoks\tabtoksEEa% + \tabtoksEEa{}% + % + % "liste vide" + \newtoks\tabtoksEEb% + \tabtoksEEb{}% + % + \readlist*\ListeSansDoublonsEE{999}% %% Pour ne pas avoir une liste vide + % + \newcount\cmptEE% + \newcount\PasNumEE% %% Permettra de savoir si ce sondage est qualitatif ou quantitatif + \PasNumEE=0\relax% + \DTLcleardb{mtdbEE}% + % on range les resultats du sondage par ordre croissant. + \foreachitem\x\in\Liste{% + \DTLnewrow{mtdbEE}% + \DTLnewdbentry{mtdbEE}{Numeric}{\x}% + }% + \dtlsort{Numeric}{mtdbEE}{\dtlicompare}% + \DTLforeach{mtdbEE}{\nba=Numeric}{% + \IfDecimal{\nba}{}{\PasNumEE=\numexpr\PasNumEE+1\relax}% + \cmptEE=0\relax% + \foreachitem\nbb\in\ListeSansDoublonsEE{% + \ifthenelse{\equal{\nba}{\nbb}}{\cmptEE=\numexpr\cmptEE+1\relax}{}% + }% + \ifthenelse{\equal{\the\cmptEE}{0}}{% + \expandafter\AjoutListEEb\nba\nil% + \xdef\listEEa{\the\tabtoksEEb}% + \ignoreemptyitems% + \setsepchar{,}% + \readlist*\ListeSansDoublonsEE\listEEa% %%% Enl\`eve tous les \'elements + %%% identiques de Liste + }{}% + }% + \foreachitem\nba\in\ListeSansDoublonsEE{% + \cmptEE=0\relax% + \DTLforeach{mtdbEE}{\nbb=Numeric}{% + \ifthenelse{\equal{\nba}{\nbb}}{\cmptEE=\numexpr\cmptEE+1\relax}{}% + }% + \expandafter\AjoutListEEab\nba\nil% + \expandafter\AjoutListEEaa\the\cmptEE\nil% %%% Compte tous les \'elements + %%% identiques de Liste + }% + \xdef\listEEb{\the\tabtoksEEa} + \ignoreemptyitems% + \setsepchar[*]{,*/}% + \readlist*\ListeComplete\listEEb% + % + \ifthenelse{\equal{\the\PasNumEE}{0}}{\setKV[ClesStat]{Quantitatif}}{\setKV[ClesStat]{Qualitatif}}% + }{% + \ifboolKV[ClesStat]{Qualitatif}{% + % % on lit la liste \'ecrite sous la forme valeur/effectif + \setsepchar[*]{,*/}\ignoreemptyitems% + \readlist*\ListeComplete{#2}% + }{% Dans le qualitatif, on trie d'abord les valeurs. + \setsepchar[*]{,*/}\ignoreemptyitems% + \readlist*\ListeInitiale{#2}% + % "liste vide" \newtoks\tabtoksEE% \tabtoksEE{}% \DTLcleardb{mtdbEEqual}% \foreachitem\x\in\ListeInitiale{% - \DTLnewrow{mtdbEEqual}% - \itemtomacro\ListeInitiale[\xcnt,1]\x% - \DTLnewdbentry{mtdbEEqual}{Val}{\x}% - \itemtomacro\ListeInitiale[\xcnt,2]\y% - \DTLnewdbentry{mtdbEEqual}{Eff}{\y}% + \DTLnewrow{mtdbEEqual}% + \itemtomacro\ListeInitiale[\xcnt,1]\x% + \DTLnewdbentry{mtdbEEqual}{Val}{\x}% + \itemtomacro\ListeInitiale[\xcnt,2]\y% + \DTLnewdbentry{mtdbEEqual}{Eff}{\y}% }% \dtlsort{Val}{mtdbEEqual}{\dtlicompare}% \DTLforeach{mtdbEEqual}{\Val=Val,\Eff=Eff}{% - \expandafter\AjoutListEEy\Val\nil% - \expandafter\AjoutListEEx\Eff\nil% - } + \expandafter\AjoutListEEy\Val\nil% + \expandafter\AjoutListEEx\Eff\nil% + }% \xdef\listEE{\the\tabtoksEE} \ignoreemptyitems% - \setsepchar[*]{,*/} + \setsepchar[*]{,*/}% \readlist*\ListeComplete\listEE% - }}} + }}}% % on cr\'ee la base de donn\'ees des valeurs dans le cas qualitatif \DTLcleardb{mtdb}% % on les trie pour la m\'ediane dans le cas qualitatif % Touhami / Texnique.fr @@ -6991,7 +7674,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \dtlsort{Numeric}{mtdb}{\dtlicompare}% % % on r\'einitialise les valeurs des crit\`eres de position et de % dispersion - \renewcommand\NbDonnees{} + \renewcommand\NbDonnees{}% \renewcommand\SommeDonnees{}% \renewcommand\EffectifTotal{}% \renewcommand\Moyenne{}% @@ -7007,7 +7690,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl % %% celui de l'effectif total \ifboolKV[ClesStat]{EffectifTotal}{% \ifboolKV[ClesStat]{Liste}{L'effectif total de la s\'erie est - \num{\ListeCompletelen}.\par}{ + \num{\ListeCompletelen}.\par}{% \foreachitem\don\in\ListeComplete{\xdef\EffectifTotal{\fpeval{\EffectifTotal+\ListeComplete[\doncnt,2]}}}% L'effectif total de la s\'erie est : \[\ListeComplete[1,2]\xintFor* ##1 in {\xintSeq {2}{\ListeCompletelen}}\do{% @@ -7017,30 +7700,30 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl % %% celui de la moyenne \xdef\Moyenne{\fpeval{\SommeDonnees/\ListeCompletelen}}% \ifboolKV[ClesStat]{Moyenne}{% - \ifboolKV[ClesStat]{Liste}{% - La somme des donn\'ees de la s\'erie est :% - \xintifboolexpr{\ListeCompletelen<\useKV[ClesStat]{Coupure}}{% - \[ - \num{\ListeComplete[1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\xintFor* ##1 in {\xintSeq {2}{\ListeCompletelen}}\do{% - +\num{\ListeComplete[##1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} - }=\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}% - \]}{% - \[ - \num{\ListeComplete[1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\xintFor* ##1 in {\xintSeq {2}{3}}\do{% - +\num{\ListeComplete[##1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}}+\dots\xintFor* ##1 in {\xintSeq {\ListeCompletelen-1}{\ListeCompletelen}}\do{% - +\num{\ListeComplete[##1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} - }=\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}% - \]% - }% - \ifboolKV[ClesStat]{SET}{}{Le nombre de donn\'ees de la s\'erie est \num{\ListeCompletelen}.\\}% - Donc la moyenne de la s\'erie est \'egale \`a :% - \[\frac{\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}}{\num{\ListeCompletelen}}%\IfInteger{\fpeval{round(\fpeval{\SommeDonnees/\ListeCompletelen},\useKV[ClesStat]{Precision})}}{=}{\approx} - \opdiv*{\SommeDonnees}{\ListeCompletelen}{resultatmoy}{restemoy}% - \opround{resultatmoy}{\useKV[ClesStat]{Precision}}{resultatmoy1}% - \opcmp{resultatmoy}{resultatmoy1}\ifopeq=\else\approx\fi% - \num{\fpeval{round(\fpeval{\SommeDonnees/\ListeCompletelen},\useKV[ClesStat]{Precision})}}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}.}{.}% - \]% - }{Pas de moyenne possible pour une s\'erie de donn\'ees \`a caract\`ere qualitatif.}}{}% + \ifboolKV[ClesStat]{Liste}{% + La somme des donn\'ees de la s\'erie est :% + \xintifboolexpr{\ListeCompletelen<\useKV[ClesStat]{Coupure}}{% + \[ + \num{\ListeComplete[1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\xintFor* ##1 in {\xintSeq {2}{\ListeCompletelen}}\do{% + +\num{\ListeComplete[##1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} + }=\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}% + \]}{% + \[ + \num{\ListeComplete[1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\xintFor* ##1 in {\xintSeq {2}{3}}\do{% + +\num{\ListeComplete[##1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}}+\dots\xintFor* ##1 in {\xintSeq {\ListeCompletelen-1}{\ListeCompletelen}}\do{% + +\num{\ListeComplete[##1,2]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} + }=\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}% + \]% + }% + \ifboolKV[ClesStat]{SET}{}{Le nombre de donn\'ees de la s\'erie est \num{\ListeCompletelen}.\\}% + Donc la moyenne de la s\'erie est \'egale \`a :% + \[\frac{\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}}{\num{\ListeCompletelen}}%\IfInteger{\fpeval{round(\fpeval{\SommeDonnees/\ListeCompletelen},\useKV[ClesStat]{Precision})}}{=}{\approx} + \opdiv*{\SommeDonnees}{\ListeCompletelen}{resultatmoy}{restemoy}% + \opround{resultatmoy}{\useKV[ClesStat]{Precision}}{resultatmoy1}% + \opcmp{resultatmoy}{resultatmoy1}\ifopeq=\else\approx\fi% + \num{\fpeval{round(\SommeDonnees/\ListeCompletelen,\useKV[ClesStat]{Precision})}}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}.}{.}% + \]% + }{Pas de moyenne possible pour une s\'erie de donn\'ees \`a caract\`ere qualitatif.}}{}% % % %% celui de l'\'etendue \xintFor* ##1 in {\xintSeq {1}{\ListeCompletelen}}\do{% \xintifboolexpr{\ListeComplete[##1,2]>\DonneeMax}{% @@ -7053,160 +7736,159 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \xdef\EffectifMax{\DonneeMax}% \xdef\Etendue{\fpeval{\DonneeMax-\DonneeMin}}% \ifboolKV[ClesStat]{Etendue}{% - \ifboolKV[ClesStat]{Liste}{% - L'\'etendue de la s\'erie est \'egale \`a $\num{\DonneeMax}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}-\num{\DonneeMin}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}=\num{\Etendue}$\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% - }{Pas d'\'etendue possible pour une s\'erie de donn\'ees \`a caract\`ere qualitatif.}}{}% + \ifboolKV[ClesStat]{Liste}{% + L'\'etendue de la s\'erie est \'egale \`a $\num{\DonneeMax}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}-\num{\DonneeMin}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}=\num{\Etendue}$\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% + }{Pas d'\'etendue possible pour une s\'erie de donn\'ees \`a caract\`ere qualitatif.}}{}% \ifboolKV[ClesStat]{Mediane}{% - \ifboolKV[ClesStat]{Liste}{% - On range les donn\'ees par ordre croissant :% - \nbdonnees=0% - \xintifboolexpr{\ListeCompletelen<\useKV[ClesStat]{Coupure}}{% - \[\DTLforeach{mtdb}{\numeroDonnee=Numeric}{\num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\DTLiflastrow{.}{;}}\]% - }{% - \medskip% - \begin{center} - \begin{minipage}{0.9\linewidth} - \DTLforeach*{mtdb}{\numeroDonnee=Numeric}{\num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\DTLiflastrow{.}{; - }\nbdonnees=\fpeval{\nbdonnees+1}\modulo{\nbdonnees}{\useKV[ClesStat]{Coupure}}\xintifboolexpr{\remainder=0}{\\}{}} - \end{minipage} - \end{center}% - \medskip% - }% - \newcount\med% - \newcount\meda% - \ifodd\number\ListeCompletelen%odd impair - \med=\fpeval{(\ListeCompletelen+1)/2}\relax% - L'effectif total de la s\'erie est \num{\ListeCompletelen}. Or, $\num{\ListeCompletelen}=\num{\fpeval{\med-1}}+1+\num{\fpeval{\med-1}}$.\\ - \else% pair - \med=\fpeval{\ListeCompletelen/2}\relax - \meda=\numexpr\med+1\relax - L'effectif total de la s\'erie est \num{\ListeCompletelen}. Or, $\num{\ListeCompletelen}=\num{\the\med}+\num{\the\med}$.\\ - \fi% - \newcount\k% - \k=0% - \DTLforeach{mtdb}{\numeroDonnee=Numeric}{\k=\numexpr\k+1\relax% - \ifnum\k=\med %La m\'ediane vaut \numeroDonnee\fi - \ifodd\number\ListeCompletelen% - La m\'ediane de la s\'erie est la \the\med\ieme{} donn\'ee.\\Donc la m\'ediane de la s\'erie est \num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% - \else% - La \the\med\ieme{} donn\'ee est \num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}\xdef\Mediane{\numeroDonnee} % - \fi - \fi - \ifnum\k=\meda - La \the\meda\ieme{} donn\'ee est \num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.} Donc la m\'ediane de la s\'erie est \xdef\Mediane{\fpeval{(\Mediane+\numeroDonnee)/2}}\num{\Mediane}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.} - \fi - } - %%%%%%%%%%%%%%%%%%%%%%%% - }{Pas de m\'ediane possible pour une s\'erie de donn\'ees \`a caract\`ere qualitatif.}}{} - % Construction du tableau - \ifboolKV[ClesStat]{Tableau}{% - \ifboolKV[ClesStat]{Liste}{Pas de tableau possible avec la cl\'e Liste.\\Utilisez plut\^ot la cl\'e Sondage si vous voulez un tableau avec cette liste.}{% - \ifboolKV[ClesStat]{Total}{\buildtabt}{\buildtab}}}% - {}% - % Construction du graphique - \ifboolKV[ClesStat]{Graphique}{% - \ifboolKV[ClesStat]{Liste}{Pas de graphique possible avec la cl\'e Liste.\\Utilisez plut\^ot la cl\'e Sondage si vous voulez un graphique avec cette liste.}{% - \ifboolKV[ClesStat]{Angle}{\buildgraphcq{360}}{\ifboolKV[ClesStat]{SemiAngle}{\buildgraphcq{180}}{\buildgraphq[#1]}}% - }}{} - }{%%%%%%%%%%%%%%%%%%%%%D\'ebut quantitatif - % % on effectue les calculs - % %% celui de la somme des donn\'ees - \foreachitem\don\in\ListeComplete{\xdef\SommeDonnees{\fpeval{\SommeDonnees+\ListeComplete[\doncnt,1]*\ListeComplete[\doncnt,2]}}}% - % %% celui de l'effectif total - \foreachitem\don\in\ListeComplete{\xdef\EffectifTotal{\fpeval{\EffectifTotal+\ListeComplete[\doncnt,2]}}}% - % %% celui de l'\'etendue - \xintFor* ##1 in {\xintSeq {1}{\ListeCompletelen}}\do{% - \xintifboolexpr{\ListeComplete[##1,1]>\DonneeMax}{% - \xdef\DonneeMax{\ListeComplete[##1,1]}% - }{}% - \xintifboolexpr{\ListeComplete[##1,1]<\DonneeMin}{% - \xdef\DonneeMin{\ListeComplete[##1,1]}% - }{}% - }% -% \xdef\EffectifMax{\DonneeMax}% - \xdef\Etendue{\fpeval{\DonneeMax-\DonneeMin}}%% - % %% celui de la moyenne - \xdef\Moyenne{\fpeval{\SommeDonnees/\EffectifTotal}}% - \ifboolKV[ClesStat]{EffectifTotal}{% - L'effectif total de la s\'erie est : \[\ListeComplete[1,2]\xintFor* ##1 in - {\xintSeq {2}{\ListeCompletelen}}\do{% - +\ListeComplete[##1,2]}=\num{\EffectifTotal}\] - }{}% - \ifboolKV[ClesStat]{Moyenne}{% - La somme des donn\'ees de la s\'erie est :% - \xintifboolexpr{\ListeCompletelen<\useKV[ClesStat]{Coupure}}{% - \[ - \ifnum\ListeComplete[1,2]=1\else\num{\ListeComplete[1,2]}\times\fi\num{\ListeComplete[1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\xintFor* ##1 in {\xintSeq {2}{\ListeCompletelen}}\do{% - +\ifnum\ListeComplete[##1,2]=1\else\num{\ListeComplete[##1,2]}\times\fi\num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} - }=\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} - \] - }{% - \[ - \ifnum\ListeComplete[1,2]=1\else\num{\ListeComplete[1,2]}\times\fi\num{\ListeComplete[1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\xintFor* ##1 in {\xintSeq {2}{2}}\do{% - +\ifnum\ListeComplete[##1,2]=1\else\num{\ListeComplete[##1,2]}\times\fi\num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} - }+\dots\xintFor* ##1 in {\xintSeq {\ListeCompletelen-1}{\ListeCompletelen}}\do{% - +\ifnum\ListeComplete[##1,2]=1\else\num{\ListeComplete[##1,2]}\times\fi\num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} - }=\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} - \] - } - \ifboolKV[ClesStat]{SET}{}{L'effectif total de la s\'erie est :% - \ifboolKV[ClesStat]{Liste}{ \num{\EffectifTotal}\\}{% - \[\num{\ListeComplete[1,2]}\xintFor* ##1 in {\xintSeq {2}{\ListeCompletelen}}\do{% - +\num{\ListeComplete[##1,2]} - }=\num{\EffectifTotal} - \]% + \ifboolKV[ClesStat]{Liste}{% + On range les donn\'ees par ordre croissant :% + \nbdonnees=0% + \xintifboolexpr{\ListeCompletelen<\useKV[ClesStat]{Coupure}}{% + \[\DTLforeach{mtdb}{\numeroDonnee=Numeric}{\num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\DTLiflastrow{.}{;}}\]% + }{% + \medskip% + \begin{center} + \begin{minipage}{0.9\linewidth} + \DTLforeach*{mtdb}{\numeroDonnee=Numeric}{\num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\DTLiflastrow{.}{; + }\nbdonnees=\fpeval{\nbdonnees+1}\modulo{\nbdonnees}{\useKV[ClesStat]{Coupure}}\xintifboolexpr{\remainder=0}{\\}{}} + \end{minipage} + \end{center}% + \medskip% }% - } - Donc la moyenne de la s\'erie est \'egale \`a :% - \[\frac{\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}}{\num{\EffectifTotal}}% - \opdiv*{\SommeDonnees}{\EffectifTotal}{resultatmoy}{restemoy}% - \opround{resultatmoy}{\useKV[ClesStat]{Precision}}{resultatmoy1}% - % Moy=\opprint{resultatmoy}--Moy1=\opprint{resultatmoy1} - \opcmp{resultatmoy}{resultatmoy1}\ifopeq=\else\approx\fi% - \num{\fpeval{round(\SommeDonnees/\EffectifTotal,\useKV[ClesStat]{Precision})}}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}.}{.} - \]% - }{}% - % % Affichage des r\'eponses. - % %% pour l'\'etendue - \ifboolKV[ClesStat]{Etendue}{L'\'etendue de la s\'erie est \'egale \`a $\num{\ListeComplete[\ListeCompletelen,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}-\num{\ListeComplete[1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}=\num{\Etendue}$\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}}{}% - % %% pour la m\'ediane - \ifboolKV[ClesStat]{Mediane}{% - - \newcount\med% - \newcount\meda% - \ifodd\number\EffectifTotal%odd impair - \med=\fpeval{(\EffectifTotal+1)/2}\relax% - L'effectif total de la s\'erie est \num{\EffectifTotal}. Or, $\num{\EffectifTotal}=\num{\fpeval{\med-1}}+1+\num{\fpeval{\med-1}}$. % - \else% pair - \med=\fpeval{\EffectifTotal/2}\relax% - \meda=\numexpr\med+1\relax% - L'effectif total de la s\'erie est \num{\EffectifTotal}. Or, $\num{\EffectifTotal}=\num{\fpeval{\med}}+\num{\fpeval{\med}}$. % - \fi% - \newcount\k% - \k=0% - \xintFor* ##1 in {\xintSeq {1}{\ListeCompletelen}}\do{% - \xintFor* ##2 in {\xintSeq {1}{\ListeComplete[##1,2]}}\do{% - \k=\numexpr\k+1\relax% - \ifnum\k=\med% - \ifodd\number\EffectifTotal% - La m\'ediane de la s\'erie est la \the\med\ieme{} donn\'ee. Donc la m\'ediane de la s\'erie est \num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% + \newcount\med% + \newcount\meda% + \ifodd\number\ListeCompletelen%odd impair + \med=\fpeval{(\ListeCompletelen+1)/2}\relax% + L'effectif total de la s\'erie est \num{\ListeCompletelen}. Or, $\num{\ListeCompletelen}=\num{\fpeval{\med-1}}+1+\num{\fpeval{\med-1}}$.\\ + \else% pair + \med=\fpeval{\ListeCompletelen/2}\relax% + \meda=\numexpr\med+1\relax% + L'effectif total de la s\'erie est \num{\ListeCompletelen}. Or, $\num{\ListeCompletelen}=\num{\the\med}+\num{\the\med}$.\\ + \fi% + \newcount\k% + \k=0% + \DTLforeach{mtdb}{\numeroDonnee=Numeric}{\k=\numexpr\k+1\relax% + \ifnum\k=\med %La m\'ediane vaut \numeroDonnee\fi + \ifodd\number\ListeCompletelen% + La m\'ediane de la s\'erie est la \the\med\ieme{} donn\'ee.\\Donc la m\'ediane de la s\'erie est \num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% \else% - La \the\med\ieme{} donn\'ee est \num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}. }{. }\xdef\Mediane{\ListeComplete[##1,1]}% - \fi% + La \the\med\ieme{} donn\'ee est \num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}\xdef\Mediane{\numeroDonnee}% \fi% - \ifnum\k=\meda% - La \the\meda\ieme{} valeur est \num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}\\Donc la m\'ediane de la s\'erie est \xdef\Mediane{\fpeval{(\Mediane+\ListeComplete[##1,1])/2}}\num{\Mediane}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% \fi% - }% + \ifnum\k=\meda + La \the\meda\ieme{} donn\'ee est \num{\numeroDonnee}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.} Donc la m\'ediane de la s\'erie est \xdef\Mediane{\fpeval{(\Mediane+\numeroDonnee)/2}}\num{\Mediane}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% + \fi% }% + %%%%%%%%%%%%%%%%%%%%%%%% + }{Pas de m\'ediane possible pour une s\'erie de donn\'ees \`a caract\`ere qualitatif.}}{}% + % Construction du tableau + \ifboolKV[ClesStat]{Tableau}{% + \ifboolKV[ClesStat]{Liste}{Pas de tableau possible avec la cl\'e Liste.\\Utilisez plut\^ot la cl\'e Sondage si vous voulez un tableau avec cette liste.}{% + \ifboolKV[ClesStat]{Total}{\buildtabt}{\buildtab}}}% + {}% + % Construction du graphique + \ifboolKV[ClesStat]{Graphique}{% + \ifboolKV[ClesStat]{Liste}{Pas de graphique possible avec la cl\'e Liste.\\Utilisez plut\^ot la cl\'e Sondage si vous voulez un graphique avec cette liste.}{% + \ifboolKV[ClesStat]{Angle}{\buildgraphcq{360}}{\ifboolKV[ClesStat]{SemiAngle}{\buildgraphcq{180}}{\buildgraphq[#1]}}% + }}{}% +}{%%%%%%%%%%%%%%%%%%%%%D\'ebut quantitatif + % % on effectue les calculs + % %% celui de la somme des donn\'ees + \foreachitem\don\in\ListeComplete{\xdef\SommeDonnees{\fpeval{\SommeDonnees+\ListeComplete[\doncnt,1]*\ListeComplete[\doncnt,2]}}}% + % %% celui de l'effectif total + \foreachitem\don\in\ListeComplete{\xdef\EffectifTotal{\fpeval{\EffectifTotal+\ListeComplete[\doncnt,2]}}}% + % %% celui de l'\'etendue + \xintFor* ##1 in {\xintSeq {1}{\ListeCompletelen}}\do{% + \xintifboolexpr{\ListeComplete[##1,1]>\DonneeMax}{% + \xdef\DonneeMax{\ListeComplete[##1,1]}% }{}% - % Construction de tableau - \ifboolKV[ClesStat]{Tableau}{\ifboolKV[ClesStat]{Total}{\buildtabt}{\buildtab}}{}% - % Construction du graphique ?? - \ifboolKV[ClesStat]{Graphique}{% - \ifboolKV[ClesStat]{Angle}{\buildgraphcq{360}}{\ifboolKV[ClesStat]{SemiAngle}{\buildgraphcq{180}}{\buildgraph[#1]}} + \xintifboolexpr{\ListeComplete[##1,1]<\DonneeMin}{% + \xdef\DonneeMin{\ListeComplete[##1,1]}% }{}% }% + % \xdef\EffectifMax{\DonneeMax}% + \xdef\Etendue{\fpeval{\DonneeMax-\DonneeMin}}%% + % %% celui de la moyenne + \xdef\Moyenne{\fpeval{\SommeDonnees/\EffectifTotal}}% + \ifboolKV[ClesStat]{EffectifTotal}{% + L'effectif total de la s\'erie est : \[\ListeComplete[1,2]\xintFor* ##1 in + {\xintSeq {2}{\ListeCompletelen}}\do{% + +\ListeComplete[##1,2]}=\num{\EffectifTotal}\] + }{}% + \ifboolKV[ClesStat]{Moyenne}{% + La somme des donn\'ees de la s\'erie est :% + \xintifboolexpr{\ListeCompletelen<\useKV[ClesStat]{Coupure}}{% + \[ + \ifnum\ListeComplete[1,2]=1\else\num{\ListeComplete[1,2]}\times\fi\num{\ListeComplete[1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\xintFor* ##1 in {\xintSeq {2}{\ListeCompletelen}}\do{% + +\ifnum\ListeComplete[##1,2]=1\else\num{\ListeComplete[##1,2]}\times\fi\num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} + }=\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} + \] + }{% + \[ + \ifnum\ListeComplete[1,2]=1\else\num{\ListeComplete[1,2]}\times\fi\num{\ListeComplete[1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}\xintFor* ##1 in {\xintSeq {2}{2}}\do{% + +\ifnum\ListeComplete[##1,2]=1\else\num{\ListeComplete[##1,2]}\times\fi\num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} + }+\dots\xintFor* ##1 in {\xintSeq {\ListeCompletelen-1}{\ListeCompletelen}}\do{% + +\ifnum\ListeComplete[##1,2]=1\else\num{\ListeComplete[##1,2]}\times\fi\num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} + }=\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{} + \] + } + \ifboolKV[ClesStat]{SET}{}{L'effectif total de la s\'erie est :% + \ifboolKV[ClesStat]{Liste}{ \num{\EffectifTotal}\\}{% + \[\num{\ListeComplete[1,2]}\xintFor* ##1 in {\xintSeq {2}{\ListeCompletelen}}\do{% + +\num{\ListeComplete[##1,2]} + }=\num{\EffectifTotal} + \]% + }% + }% + Donc la moyenne de la s\'erie est \'egale \`a :% + \[\frac{\num{\SommeDonnees}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}}{\num{\EffectifTotal}}% + \opdiv*{\SommeDonnees}{\EffectifTotal}{resultatmoy}{restemoy}% + \opround{resultatmoy}{\useKV[ClesStat]{Precision}}{resultatmoy1}% + \opcmp{resultatmoy}{resultatmoy1}\ifopeq=\else\approx\fi% + \num{\fpeval{round(\SommeDonnees/\EffectifTotal,\useKV[ClesStat]{Precision})}}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}.}{.}% + \]% + }{}% + % % Affichage des r\'eponses. + % %% pour l'\'etendue + \ifboolKV[ClesStat]{Etendue}{L'\'etendue de la s\'erie est \'egale \`a $\num{\ListeComplete[\ListeCompletelen,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}-\num{\ListeComplete[1,1]}\ifboolKV[ClesStat]{Concret}{~\text{\useKV[ClesStat]{Unite}}}{}=\num{\Etendue}$\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}}{}% + % %% pour la m\'ediane + \ifboolKV[ClesStat]{Mediane}{% + + \newcount\med% + \newcount\meda% + \ifodd\number\EffectifTotal%odd impair + \med=\fpeval{(\EffectifTotal+1)/2}\relax% + L'effectif total de la s\'erie est \num{\EffectifTotal}. Or, $\num{\EffectifTotal}=\num{\fpeval{\med-1}}+1+\num{\fpeval{\med-1}}$. % + \else% pair + \med=\fpeval{\EffectifTotal/2}\relax% + \meda=\numexpr\med+1\relax% + L'effectif total de la s\'erie est \num{\EffectifTotal}. Or, $\num{\EffectifTotal}=\num{\fpeval{\med}}+\num{\fpeval{\med}}$. % + \fi% + \newcount\k% + \k=0% + \xintFor* ##1 in {\xintSeq {1}{\ListeCompletelen}}\do{% + \xintFor* ##2 in {\xintSeq {1}{\ListeComplete[##1,2]}}\do{% + \k=\numexpr\k+1\relax% + \ifnum\k=\med% + \ifodd\number\EffectifTotal% + La m\'ediane de la s\'erie est la \the\med\ieme{} donn\'ee. Donc la m\'ediane de la s\'erie est \num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% + \else% + La \the\med\ieme{} donn\'ee est \num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}. }{. }\xdef\Mediane{\ListeComplete[##1,1]}% + \fi% + \fi% + \ifnum\k=\meda% + La \the\meda\ieme{} valeur est \num{\ListeComplete[##1,1]}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}\\Donc la m\'ediane de la s\'erie est \xdef\Mediane{\fpeval{(\Mediane+\ListeComplete[##1,1])/2}}\num{\Mediane}\ifboolKV[ClesStat]{Concret}{~\useKV[ClesStat]{Unite}.}{.}% + \fi% + }% + }% + }{}% + % Construction de tableau + \ifboolKV[ClesStat]{Tableau}{\ifboolKV[ClesStat]{Total}{\buildtabt}{\buildtab}}{}% + % Construction du graphique ?? + \ifboolKV[ClesStat]{Graphique}{% + \ifboolKV[ClesStat]{Angle}{\buildgraphcq{360}}{\ifboolKV[ClesStat]{SemiAngle}{\buildgraphcq{180}}{\buildgraph[#1]}} + }{}% +}% }% %%% @@ -7850,7 +8532,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl %%% % Application : pourcentage %%% -\setKVdefault[ClesPourcentage]{Appliquer,Calculer=false,Augmenter=false,Reduire=false,Fractionnaire=false,Decimal,Formule=false,Unite=g,Concret=false,GrandeurA=Grandeur A,GrandeurB=Total,MotReduction=diminution,AideTableau=false,ColorFill=white,CouleurTab=gray!15} +\setKVdefault[ClesPourcentage]{Appliquer,Calculer=false,Augmenter=false,Reduire=false,Fractionnaire=false,Decimal,Formule=false,Unite=g,Concret=false,GrandeurA=Grandeur A,GrandeurB=Total,Largeur=1cm,MotReduction=diminution,AideTableau=false,ColorFill=white,CouleurTab=gray!15} \newcommand\Pourcentage[3][]{% \useKVdefault[ClesPourcentage]% @@ -7865,8 +8547,9 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \xdef\NomA{\useKV[ClesPourcentage]{GrandeurA}}% \xdef\NomB{\useKV[ClesPourcentage]{GrandeurB}}% \xdef\NomCouleurTab{\useKV[ClesPourcentage]{CouleurTab}}% + \xdef\NomLargeurTab{\useKV[ClesPourcentage]{Largeur}}% \begin{center} - \Propor[GrandeurA=\NomA,GrandeurB=\NomB,CouleurTab=\NomCouleurTab]{/#3,#2/100} + \Propor[GrandeurA=\NomA,GrandeurB=\NomB,CouleurTab=\NomCouleurTab,Largeur=\NomLargeurTab]{/#3,#2/100} \end{center} \FlecheCoefInv{\tiny$\times\num{\fpeval{#2/100}}$}% On obtient une \useKV[ClesPourcentage]{MotReduction} de $\num{\fpeval{#2/100}}\times\num{#3}\ifboolKV[ClesPourcentage]{Concret}{~\text{\useKV[ClesPourcentage]{Unite}}}{}=\num{\fpeval{#3*#2/100}}$\ifboolKV[ClesPourcentage]{Concret}{~\useKV[ClesPourcentage]{Unite}}{}. Donc un total de $\num{#3}\ifboolKV[ClesPourcentage]{Concret}{~\text{\useKV[ClesPourcentage]{Unite}}}{}-\num{\fpeval{#3*#2/100}}\ifboolKV[ClesPourcentage]{Concret}{~\text{\useKV[ClesPourcentage]{Unite}}}{}=\num{\fpeval{#3*(1-#2/100)}}$\ifboolKV[ClesPourcentage]{Concret}{~\useKV[ClesPourcentage]{Unite}}{}.% @@ -7885,8 +8568,9 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \xdef\NomA{\useKV[ClesPourcentage]{GrandeurA}}% \xdef\NomB{\useKV[ClesPourcentage]{GrandeurB}}% \xdef\NomCouleurTab{\useKV[ClesPourcentage]{CouleurTab}}% + \xdef\NomLargeurTab{\useKV[ClesPourcentage]{Largeur}}% \begin{center}% - \Propor[GrandeurA=\NomA,GrandeurB=\NomB,CouleurTab=\NomCouleurTab]{/#3,#2/100}% + \Propor[GrandeurA=\NomA,GrandeurB=\NomB,CouleurTab=\NomCouleurTab,Largeur=\NomLargeurTab]{/#3,#2/100}% \end{center}% \FlecheCoefInv{\tiny$\times\num{\fpeval{#2/100}}$}% On obtient une augmentation de $\num{\fpeval{#2/100}}\times\num{#3}\ifboolKV[ClesPourcentage]{Concret}{~\text{\useKV[ClesPourcentage]{Unite}}}{}=\num{\fpeval{#3*#2/100}}$\ifboolKV[ClesPourcentage]{Concret}{~\useKV[ClesPourcentage]{Unite}}{}.\\Donc un total de $\num{#3}\ifboolKV[ClesPourcentage]{Concret}{~\text{\useKV[ClesPourcentage]{Unite}}}{}+\num{\fpeval{#3*#2/100}}\ifboolKV[ClesPourcentage]{Concret}{~\text{\useKV[ClesPourcentage]{Unite}}}{}=\num{\fpeval{#3*(1+#2/100)}}$\ifboolKV[ClesPourcentage]{Concret}{~\useKV[ClesPourcentage]{Unite}}{}.% @@ -7899,7 +8583,8 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \xdef\NomA{\useKV[ClesPourcentage]{GrandeurA}}% \xdef\NomB{\useKV[ClesPourcentage]{GrandeurB}}% \xdef\NomCouleurTab{\useKV[ClesPourcentage]{CouleurTab}}% - \Propor[GrandeurA=\NomA,GrandeurB=\NomB,CouleurTab=\NomCouleurTab]{#2/#3,/100}% + \xdef\NomLargeurTab{\useKV[ClesPourcentage]{Largeur}}% + \Propor[GrandeurA=\NomA,GrandeurB=\NomB,CouleurTab=\NomCouleurTab,Largeur=\NomLargeurTab]{#2/#3,/100}% \xdef\colorfill{\useKV[ClesPourcentage]{ColorFill}}% \FlechesPB{2}{1}{\scriptsize$\times\num{\fpeval{#3/100}}$}% \FlechesPH{1}{2}{\scriptsize$\div\num{\fpeval{#3/100}}$}% @@ -7915,14 +8600,14 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl %%% % Lien : ratio %%% -\setKVdefault[ClesRatio]{Figure=false,Longueur=5cm,TexteTotal=quantit\'e,TextePart=part,Tableau=false,GrandeurA=Grandeur A,GrandeurB=Part(s),Largeur=1cm,Stretch=1,Nom=false,CouleurUn=gris,CouleurDeux=0.5gris+0.5blanc,CouleurTrois=white,CouleurTab=gray!15} +\setKVdefault[ClesRatio]{FigureCours=false,Figure=false,Longueur=5cm,TexteTotal=quantit\'e,TextePart=part,Tableau=false,GrandeurA=Grandeur A,GrandeurB=Part(s),Largeur=1cm,Stretch=1,Nom=false,CouleurUn=gris,CouleurDeux=0.5gris+0.5blanc,CouleurTrois=white,CouleurTab=gray!15} \newcommand\MPTest[9][]{% % #2 : Longueur de la barre unit\'e % #3 : premier nombre % #4 : deuxi\`eme nombre % #5 : troisi\`eme nombre - % #6 : Valeurs du ratio + % #6 : ne sert à rien. Laissé en attente. % #7 \`a #9: Couleurs de remplissage \ifluatex \mplibforcehmode @@ -7942,7 +8627,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl % on fait la somme totale "du ratio" somme=0; somme:=somme for k=1 upto n:+N[k] endfor; - Figure(0,0,long+2u,3u); + %Figure(0,0,long+2u,3u); remplis polygone(A,(N[1]/somme)[A,B],(N[1]/somme)[D,C],D) withcolor #7; remplis polygone(B,(N[1]/somme)[A,B],(N[1]/somme)[D,C],C) @@ -7975,7 +8660,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl to"&decimal(abs(((N[1]+N[2])/somme)[A,B]-B))&"pt{}}$"),iso(B,((N[1]+N[2])/somme)[A,B])); fi; enddef; - RatioTrois(#2)(#6); + RatioTrois(#2)(#3,#4,#5); %etiquettage labeloffset:=labeloffset*3; label.top(btex \useKV[ClesRatio]{TexteTotal} etex,iso(D,C)); @@ -8051,7 +8736,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl to"&decimal(abs(((N[1]+N[2])/somme)[A,B]-B))&"pt{}}$"),iso(B,((N[1]+N[2])/somme)[A,B])); fi; enddef; - RatioTrois(#2)(#6); + RatioTrois(#2)(#3,#4,#5); %etiquettage labeloffset:=labeloffset*3; label.top(\btex \useKV[ClesRatio]{TexteTotal} etex,iso(D,C)); @@ -8078,6 +8763,127 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \fi } +\newcommand\MPTestCours[9][]{% + % #2 : Longueur de la barre unit\'e + % #3 : premier nombre + % #4 : deuxi\`eme nombre + % #5 : troisi\`eme nombre + % #6 : Valeurs du ratio + % #7 \`a #9: Couleurs de remplissage + \ifluatex + \mplibforcehmode + \begin{mplibcode} + vardef RatioTrois(expr long)(text t)=%longueur de la barre / quantit\'e \`a partager / textepart :) / t le ratio + pair A,B,C,D; + A=u*(1,1); + B-A=(long,0); + C-B=u*(0,0.5); + D-C=A-B; + n:=0;%n pour savoir si le ratio est a:b ou a:b:c + numeric N[];%Pour sauvegarder les \'el\'ements du ratio + for p_=t: + n:=n+1; + N[n]=p_; + endfor; + % on fait la somme totale "du ratio" + somme=0; + somme:=somme for k=1 upto n:+N[k] endfor; + %%Figure(0,0,long+2u,3u); + remplis polygone(A,(N[1]/somme)[A,B],(N[1]/somme)[D,C],D) + withcolor #7; + remplis polygone(B,(N[1]/somme)[A,B],(N[1]/somme)[D,C],C) + withcolor #8; + if n>2: + remplis + polygone((N[1]/somme)[A,B],((N[1]+N[2])/somme)[A,B],((N[1]+N[2])/somme)[D,C],(N[1]/somme)[D,C]) + withcolor #8; + remplis + polygone(B,((N[1]+N[2])/somme)[A,B],((N[1]+N[2])/somme)[D,C],C) + withcolor #9; + fi; + drawoptions(withpen pencircle scaled1.5bp); + draw polygone(A,B,C,D); + for k=1 upto somme-1: + draw segment((k/somme)[A,B],(k/somme)[D,C]); + endfor; + drawoptions(); + % accolades + label.bot(TEX("\footnotesize$\underbrace{\hbox + to"&decimal(abs((N[1]/somme)[A,B]-A))&"pt{}}$"),iso(A,(N[1]/somme)[A,B])); + label.bot(TEX("\footnotesize$\underbrace{\hbox + to"&decimal(abs((N[1]/somme)[A,B]-((N[1]+N[2])/somme)[A,B]))&"pt{}}$"),iso(((N[1]+N[2])/somme)[A,B],(N[1]/somme)[A,B])); + if n>2: + label.bot(TEX("\footnotesize$\underbrace{\hbox + to"&decimal(abs(((N[1]+N[2])/somme)[A,B]-B))&"pt{}}$"),iso(B,((N[1]+N[2])/somme)[A,B])); + fi; + enddef; + RatioTrois(#2)(#3,#4,#5); + %etiquettage + labeloffset:=labeloffset*3; + label.bot(btex $a$ etex,iso(A,(N[1]/somme)[A,B])); + label.bot(btex $b$ etex,iso(((N[1]+N[2])/somme)[A,B],(N[1]/somme)[A,B])); + if n>2: + label.bot(btex $c$ etex,iso(B,((N[1]+N[2])/somme)[A,B])); + fi; + \end{mplibcode} + \else + \begin{mpost} + vardef RatioTrois(expr long)(text t)=%longueur de la barre / quantit\'e \`a partager / textepart :) / t le ratio + pair A,B,C,D; + A=u*(1,1); + B-A=(long,0); + C-B=u*(0,0.5); + D-C=A-B; + n:=0;%n pour savoir si le ratio est a:b ou a:b:c + numeric N[];%Pour sauvegarder les \'el\'ements du ratio + for p_=t: + n:=n+1; + N[n]=p_; + endfor; + % on fait la somme totale "du ratio" + somme=0; + somme:=somme for k=1 upto n:+N[k] endfor; + %Figure(0,0,long+2u,3u); + remplis polygone(A,(N[1]/somme)[A,B],(N[1]/somme)[D,C],D) + withcolor #7; + remplis polygone(B,(N[1]/somme)[A,B],(N[1]/somme)[D,C],C) + withcolor #8; + if n>2: + remplis + polygone((N[1]/somme)[A,B],((N[1]+N[2])/somme)[A,B],((N[1]+N[2])/somme)[D,C],(N[1]/somme)[D,C]) + withcolor #8; + remplis + polygone(B,((N[1]+N[2])/somme)[A,B],((N[1]+N[2])/somme)[D,C],C) + withcolor #9; + fi; + drawoptions(withpen pencircle scaled1.5bp); + draw polygone(A,B,C,D); + for k=1 upto somme-1: + draw segment((k/somme)[A,B],(k/somme)[D,C]); + endfor; + drawoptions(); + % accolades + label.bot(LATEX("\noexpand\footnotesize$\noexpand\underbrace{\noexpand\hbox + to"&decimal(abs((N[1]/somme)[A,B]-A))&"pt{}}$"),iso(A,(N[1]/somme)[A,B])); + label.bot(LATEX("\noexpand\footnotesize$\noexpand\underbrace{\noexpand\hbox + to"&decimal(abs((N[1]/somme)[A,B]-((N[1]+N[2])/somme)[A,B]))&"pt{}}$"),iso(((N[1]+N[2])/somme)[A,B],(N[1]/somme)[A,B])); + if n>2: + label.bot(LATEX("\noexpand\footnotesize$\noexpand\underbrace{\noexpand\hbox + to"&decimal(abs(((N[1]+N[2])/somme)[A,B]-B))&"pt{}}$"),iso(B,((N[1]+N[2])/somme)[A,B])); + fi; + enddef; + RatioTrois(#2)(#3,#4,#5); + %etiquettage + labeloffset:=labeloffset*3; + label.bot(btex $a$ etex,iso(A,(N[1]/somme)[A,B])); + label.bot(btex $b$ etex,iso(((N[1]+N[2])/somme)[A,B],(N[1]/somme)[A,B])); + if n>2: + label.bot(btex $c$ etex,iso(B,((N[1]+N[2])/somme)[A,B])); + fi; + \end{mpost} + \fi +} + \newtoks\toklisteratio \def\UpdateRatio#1\nil{\addtotok\toklisteratio{#1,}} @@ -8139,25 +8945,35 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \useKVdefault[ClesRatio]% \setKV[ClesRatio]{#1}% \xdef\EcartLargeur{\useKV[ClesRatio]{Largeur}}% - \ifboolKV[ClesRatio]{Figure}{% + \ifboolKV[ClesRatio]{FigureCours}{% \ignoreemptyitems% \readlist*\ListeRatio{#2}% \toklisteratio{}% \foreachitem\compteur\in\ListeRatio{\expandafter\UpdateRatio\compteur\nil}% - \itemtomacro\ListeRatio[1]\NbUn - \itemtomacro\ListeRatio[2]\NbDeux - \xintifboolexpr{\ListeRatiolen>2}{\itemtomacro\ListeRatio[3]\NbTrois}{\xdef\NbTrois{}} - \MPTest[#1]{\useKV[ClesRatio]{Longueur}}{\NbUn}{\NbDeux}{\NbTrois}{\the\toklisteratio}{\useKV[ClesRatio]{CouleurUn}}{\useKV[ClesRatio]{CouleurDeux}}{\useKV[ClesRatio]{CouleurTrois}}% + \itemtomacro\ListeRatio[1]\NbUn% + \itemtomacro\ListeRatio[2]\NbDeux% + \xintifboolexpr{\ListeRatiolen>2}{\itemtomacro\ListeRatio[3]\NbTrois}{\xdef\NbTrois{}}% + \MPTestCours[#1]{\useKV[ClesRatio]{Longueur}}{\NbUn}{\NbDeux}{\NbTrois}{\the\toklisteratio}{\useKV[ClesRatio]{CouleurUn}}{\useKV[ClesRatio]{CouleurDeux}}{\useKV[ClesRatio]{CouleurTrois}}% }{% - \ifboolKV[ClesRatio]{Tableau}{% - \setsepchar[*]{,*/}\ignoreemptyitems% + \ifboolKV[ClesRatio]{Figure}{% + \ignoreemptyitems% \readlist*\ListeRatio{#2}% - \buildtabratio% - }{}% + \toklisteratio{}% + \foreachitem\compteur\in\ListeRatio{\expandafter\UpdateRatio\compteur\nil}% + \itemtomacro\ListeRatio[1]\NbUn% + \itemtomacro\ListeRatio[2]\NbDeux% + \xintifboolexpr{\ListeRatiolen>2}{\itemtomacro\ListeRatio[3]\NbTrois}{\xdef\NbTrois{}}% + \MPTest[#1]{\useKV[ClesRatio]{Longueur}}{\NbUn}{\NbDeux}{\NbTrois}{\the\toklisteratio}{\useKV[ClesRatio]{CouleurUn}}{\useKV[ClesRatio]{CouleurDeux}}{\useKV[ClesRatio]{CouleurTrois}}% + }{% + \ifboolKV[ClesRatio]{Tableau}{% + \setsepchar[*]{,*/}\ignoreemptyitems% + \readlist*\ListeRatio{#2}% + \buildtabratio% + }{}% + }% }% }% - -%%% +%%% % Cartes Mentales %%% \setKVdefault[ClesMentales]{Nom={Bulle}, Largeur=5cm, Ancre={0,0},Pointilles=false,CTrace=black,CFond=white,Epaisseur=1pt,Rayon=1}% @@ -11802,7 +12618,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl % #4 : on affiche le nom des points ou pas % #5 : quelle est la valeur de la longueur unit\'e ? % #6 : la valeur de l'unit\'e - % #7 : on affiche les abscisses ou pas : 0 non, 1 oui, 2 fraction + % #7 : on affiche les abscisses ou pas : 0 non, 1 oui, 2 fraction, 3 Fleche dots % #8 : on affiche tous les multiples de la graduation "principale" \ifluatex \mplibforcehmode @@ -11833,7 +12649,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl fi; enddef; toto(#3); - Figure((minx-1)*unitp,-u,(maxx+1)*unitp,u); + Figure((minx-1)*unitp,-2u,(maxx+1)*unitp,u); pair A,B,C; A=(0,0); B=unitp*(maxx,0); @@ -11888,7 +12704,20 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl fi; endfor; fi; - if #7=2: + if #7=3: + for p_=t: + if numeric p_: + k:=p_; + fi; + if string p_: + if p_<>"": + drawarrow (unitp*(k,-1))--(unitp*(k,-0.3)); + label.bot(btex \hbox to2em{\dotfill} etex,(unitp*(k,-1))); + pointe(unitp*(k-#6,0)); + fi; + fi; + endfor; + elseif #7=2: for p_=t: if numeric p_: k:=p_; @@ -11948,7 +12777,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl fi; enddef; toto(#3); - Figure((minx-1)*unitp,-u,(maxx+1)*unitp,u); + Figure((minx-1)*unitp,-2u,(maxx+1)*unitp,u); pair A,B,C; A=(0,0); B=unitp*(maxx,0); @@ -12003,7 +12832,20 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl fi; endfor; fi; - if #7=2: + if #7=3: + for p_=t: + if numeric p_: + k:=p_; + fi; + if string p_: + if p_<>"": + drawarrow (unitp*(k,-1))--(unitp*(k,-0.3)); + label.bot(\btex \hbox to2em{\dotfill} etex,(unitp*(k,-1))); + pointe(unitp*(k-#6,0)); + fi; + fi; + endfor; + elseif #7=2: for p_=t: if numeric p_: k:=p_; @@ -13320,7 +14162,7 @@ Unite={},Largeur=1cm,Precision=2,Donnee=Valeurs,Effectif=Effectif,Origine=0,Angl \ifnum\cntcol<\useKV[Tableur]{Colonnes} \advance\cntcol\@ne \addtot@b{&}% - \edftot@b{{\noexpand\@Alph\the\cntcol}}% + \edftot@b{{\noexpand\@Alph{\the\cntcol}}}% \repeat \addtot@b{\\&}% \collectcp@body}{\the\t@b} diff --git a/macros/latex/contrib/profcollege/metapost/PfCGeometrie.mp b/macros/latex/contrib/profcollege/metapost/PfCGeometrie.mp index 222df57419..2e3cc54dd2 100644 --- a/macros/latex/contrib/profcollege/metapost/PfCGeometrie.mp +++ b/macros/latex/contrib/profcollege/metapost/PfCGeometrie.mp @@ -607,11 +607,19 @@ vardef polygone(text t)= aaa[j+1]:=aaa[1]; save $; path $; - $=aaa1-- - for k=2 upto j: - aaa[k]-- - endfor - cycle; + if typetrace="mainlevee": + $=segment(aaa[1],aaa[2])-- + for k=2 upto (j-1): + segment(aaa[k],aaa[k+1])-- + endfor + segment(aaa[j],aaa[1])--cycle; + else: + $=aaa1-- + for k=2 upto j: + aaa[k]-- + endfor + cycle; + fi; $ enddef; |