summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/projlib/projlib-text.sty
blob: 769ca911aaf5347fdbd78c099d86198c6d140b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%%
%% This is file `projlib-text.sty',
%% generated with the docstrip utility.
%%
%% Copyright (C) 2021-2023 by Jinwen XU
%% 
%% This is part of the ProjLib Toolkit.
%% 
%% This work may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[2022-06-01]
\ProvidesExplPackage
  {projlib-text}
  {2023/11/05} {}
  {Text-related commands}

\keys_define:nn { projlib-text }
  {
    , unknown .code:n       = {}
  }
\ProcessKeyOptions [ projlib-text ]

\RequirePackage { projlib-paper }

\ProvideDocumentCommand \ItemDescription { m }
  {
    \textcolor { main-text!50!paper } { $($ #1 $)$  }
    \nobreakspace
    \ignorespaces
  }

\cs_new_protected:Nn \projlib_text_abbreviation_generic:nn
  % #1 is the text
  % #2 is usually some spacing adjustment
  {
    #1
    % if followed by a dot, then remove that dot and adjust the spacing
    \peek_meaning_ignore_spaces:NTF .
      { #2 \use_none:n }
      {
        % if followed by a comma, then act like nothing happens
        % otherwise adjust the spacing
        \peek_meaning_ignore_spaces:NTF ,
          { \prg_do_nothing: }
          { #2 }
      }
  }

\hook_gput_code:nnn { begindocument/before } { projlib-text }
  {
    % i.e.
    \ProvideDocumentCommand { \ie } { }
      {
        \projlib_text_abbreviation_generic:nn { \textit{i. \nobreak \hskip.2ex \nobreak e.} } { \skip_horizontal:n { -.15ex ~plus -.15\tex_fontdimen:D 3 \tex_font:D~minus -.15\tex_fontdimen:D 4 \tex_font:D } }
      }

    % e.g.
    \ProvideDocumentCommand { \eg } { }
      {
        \projlib_text_abbreviation_generic:nn { \textit{e. \nobreak \hskip.2ex \nobreak g.} } { \skip_horizontal:n { -.15ex ~plus -.15\tex_fontdimen:D 3 \tex_font:D~minus -.15\tex_fontdimen:D 4 \tex_font:D } }
      }

    % cf.
    \ProvideDocumentCommand { \cf } { }
      {
        \projlib_text_abbreviation_generic:nn { \textit{cf.} } { }
      }

    % etc.
    \ProvideDocumentCommand { \etc } { }
      {
        \projlib_text_abbreviation_generic:nn { etc. } { }
      }
  }

\endinput
%%
%% End of file `projlib-text.sty'.