39

I'm a pretty decent LaTeX user in the sense that I write LaTeX documents all the time and I can do pretty much everything that I need to do (with some occasional help from you lovely people). But I don't know much about plain TeX and TeX's inner workings, and I don't need to know it for most of what I do.

I would like to learn more though, and I can't get motivated unless there's something actually useful for me to do with it.

So I was hoping you guys would have some suggestions of stuff that has to be done, so I can learn what's necessary and do it. Something actually useful for the TeX community, but simple enough to be a starting point (it can be challenging, though; that's the whole point).

I also wanted to know more about LaTeX 3, so I was thinking maybe something related to expl3 could be nice. Even, like, a single function that needs some work, and I could try to give it a go. Anyway, something to make me feel like I'm doing something worthwhile while I learn.

Even better, if you guys are feeling up for it, would be a whole set of progressive tasks, like:

Easy stuff:

  • Write this function
  • Fix this problem
  • Document this code

Harder stuff:

  • Add this feature

And so on…

If there were a list of enough tasks that need to be done (even if they're those annoying parts everyone's procrastinating), maybe more people would be interested in tackling them too, and it would make it more interesting for people to learn stuff while at the same time helping current projects.

percusse
  • 157,807
dbmrq
  • 1,299
  • 2
    Upvoted for your interest and willingness to help, but I agree with Werner that it's not a great fit for the site. In addition to chat, the latex-l mailing list may be another place to get the discussion going. – Paul Gessler Dec 08 '17 at 19:52
  • 2
    Oh, all right then, I'll ask on the chat and mailing list when I have the time. Thanks you! – dbmrq Dec 09 '17 at 03:09
  • 2
    There are plenty of projects here: https://github.com/latex3/latex3/issues – Henri Menke Dec 11 '17 at 20:35
  • @HenriMenke Oh, that's great, I didn't know LaTeX 3 was on GitHub. Thanks. :) – dbmrq Dec 11 '17 at 22:44
  • 1
    Did you find something? I'm curious. Perhaps email me, stefan@latex.org. – Stefan Kottwitz Jan 06 '18 at 19:19
  • 1
    @StefanKottwitz Thanks! I opened this question on Meta because I thought it could get a conversation going and some general starting point ideas for other people too, but I've been really busy lately, so now I'm waiting until I can have some free time to really get into it, then I'll check the GitHub issues and depending on how it goes I'll send you a message. :) – dbmrq Jan 06 '18 at 19:28
  • 3
    It's just that I got ideas to share. :-) – Stefan Kottwitz Jan 06 '18 at 19:52

1 Answers1

1

I'm in the same boat!

I've been piecing together a simple package that enables declaring and using text "styles".

I wrote a fairly robust class for dissertations (desert.cls), but wanted to allow key--value options that behave like this:

\documentclass[
    style/footnote       = {small,sans,FF0000},
    style/chapter-name   = uppercase,
    style/source-code    = \myfancymacro,
]{desert}

Each style is a comma-separated list of:

  • font series or shape;
  • an xcolor color;
  • a user-defined macro;
  • uppercase, lowercase, sentence case, etc.
  • possibly font face and/or microtype options in the future

Let me know if you would be interested in finishing this and sending it to CTAN together. Here's my current attempt.

txtstyles.sty

\RequirePackage{xparse}
\RequirePackage{l3keys2e}
\RequirePackage{etoolbox}
\ProvidesExplPackage{txtstyles}{2022-02-02}{0.1}{Text styles}
\RequirePackage[
    dvipsnames,svgnames,x11names,
    hyperref
]{xcolor}
\RequirePackage{fontspec}
\RequirePackage{fontsize}
\RequirePackage{caption}
\RequirePackage{microtype}

%=================================================================== % text commands and aliases %===================================================================

\NewDocumentCommand{\txtsub}{+m}{\textsubscript{#1}} \NewDocumentCommand{\txtsup}{+m}{\textsuperscript{#1}} \NewDocumentCommand{\txtuppercase}{+m}{\text_uppercase:n{#1}} \NewDocumentCommand{\txtlowercase}{+m}{\text_lowercase:n{#1}}

% converts capital letters to small-caps but leaves lowercase % Great for mixed-case acronyms like "ChEMBL", and acronyms no longer stand out % https://tex.stackexchange.com/questions/39831/uppercase-smallcaps-with-latex-not-xelatex \NewDocumentCommand{\txtuptosc}{+m} { \tl_set:Nn \l_tmpa_tl {#1} \regex_replace_all:nnN { ([A-Z]+) } { \c{textsc} \cB{ \c{lowercase} \cB{ \1 \cE} \cE} } \l_tmpa_tl \tl_use:N \l_tmpa_tl }

% Just for symmetry with \txtuptosc \NewDocumentCommand{\txtalltosc}{+m} { \textsc{\text_lowercase:n{#1}} }

% Uppercase first character; lowercase the rest \NewDocumentCommand{\txtsentencecase}{+m} { TODO } % Uppercase first character and each first character after punctuation; lowercase the rest % E.g. "\txttitlecase{grab a red one}" --> Grab A Red One \NewDocumentCommand{\txttitlecase}{+m} { TODO }

\NewDocumentCommand{\txttomath}{+m} { \ensuremath{#1} }

%=================================================================== % main code %===================================================================

% build up aliases for style commands \prop_new:N \g_txtstyle_aliases \prop_new:N \g_txtstyle_aliases_tmp \prop_set_from_keyval:Nn \g_txtstyle_aliases_tmp { normal=normalfont, rm=rmfamily, % families roman=rmfamily, sf=sffamily, sans=sffamily, tt=ttfamily, mono=ttfamily, md=mediumseries, % series - -medium medium=mediumseries, bf=bfseries, % series -- bold bold=bfseries, textbf=bfseries, up=upshape, % shapes -- upright upright=upshape, it=itshape, % shapes -- italic italic=itshape, textit=itshape, sl=slshape, % shapes -- slant slant=slshape, slanted=slshape, textsl=slshape, sw=swshape, swash=swshape, % shapes -- swash textsw=swshape, sc=scshape, % shapes -- smallcaps smallcaps=scshape, textsc=scshape, sub=txtsub, % sub/superscript subscript=txtsub, sup=txtsup, superscript=txtsup, upcase=txtuppercase, % lower/uppercase uppercase=txtuppercase, downcase=txtlowercase, lowercase=txtlowercase, uptosc=txtuppertosc, % fancy cases alltosc=txtalltosc, sentencecase=txtsentencecase, titlecase=txttitlecase, wee=scriptsize, % sizes -- script (avoid functional name) weer=scriptsizer, weerr=scriptsizerr, weerrr=scriptsizerrr, mini=footnotesize, % sizes -- footnote (avoid functional name) minir=footnotesizer, minirr=footnotesizerr, minirrr=footnotesizerrr, mid=normalsize, % sizes -- normal (just hate the suffix) midr=normalsizer, midrr=normalsizerr, midrrr=normalsizerrr } % add the values themselves as keys \prop_map_inline:Nn \g_txtstyle_aliases_tmp { \prop_put:Nnn \g_txtstyle_aliases {#2}{#2} \prop_put:Nnn \g_txtstyle_aliases {#1}{#2} } \tl_log:n{\g_txtstyle_aliases}

% call \DeclareCaptionFont for all nonstandard options \seq_new:N \g_txtstyle_caption \seq_set_from_clist:Nn \g_txtstyle_capstyles { rm,sf,tt,up,it,sl,md,bf,scriptsize,footnotesize,normalsize,large,Large } \prop_map_inline:Nn \g_txtstyle_aliases { \prop_if_in:NnF \g_txtstyle_capstyles {#1} { \DeclareCaptionFont{#1}{ \cs:w #2 \cs_end: } } }

\msg_new:nnn{txtstyles}{notunderstood}{Command\ /\ name\ '#1'\ not\ understood\ while\ declaring\ style\ '#2'.} \msg_new:nnn{txtstyles}{stylemissing}{Cannot\ use\ style\ '#1':\ it\ is\ not\ defined.} \msg_new:nnn{txtstyles}{stylenotdefined}{Style\ '#1'\ is\ not\ defined;\ cannot\ renew.} \msg_new:nnn{txtstyles}{styledefined}{Style\ '#1'\ is\ already\ defined;\ cannot\ define.} \cs_new:Npn\notunderstooderr:n #1 { \msg_error:nnn{txtstyles}{notunderstood}{#1} } \cs_new:Npn\stylemissingerr:n #1 { \msg_error:nnn{txtstyles}{stylemissing}{#1} } \cs_new:Npn\stylenotdefderr:n #1 { \msg_error:nnn{txtstyles}{stylenotdefined}{#1} } \cs_new:Npn\styledefderr:n #1 { \msg_error:nnn{txtstyles}{styledefined}{#1} }

% converts a single name, like "LARGE", \bf, or "red" to a command \cs_new:Npn \convert_cmd:n #1 { \cs_if_exist_use:cTF{#1} {} % option 1: a command that starts with
{ % options 2 (named alias) and 3 (color) \prop_get:NnNTF \g_txtstyle_aliases {#1} {} { \color{#1} } } }

% defines a new style as a list of commands (via \convert_cmd) \NewDocumentCommand{\DeclareTxtStyle}{m >{\SplitList{,}}m} { \cs_gset:cpn{g_txtstyle_#1:n} {#1} { \tl_new:N\mytl \tl_set:Nn\mytl{#1} \tl_map_inline:cn {##2} { \tl_set:Nn\convert_cmd:n{#1}{\mytl} } \mytl } }

% related commands a la [New/Renew/etc.]DocumentCommand

\NewDocumentCommand{\NewTxtStyle}{mm} { \cs_if_free:cTF { g_txtstyle_#1:n } { \DeclareTxtStyle {#1} {#2} } { \styledefderr:n{#1} } }

\NewDocumentCommand{\AliasTxtStyle}{mm} { \cs_if_exist:cTF { g_txtstyle_#2:n } { \cs_gset:cpn{g_txtstyle_#1:n} #2 } {\stylenotdefderr:n{#1} } }

\NewDocumentCommand{\NewAliasTxtStyle}{mm} { \cs_if_exist:cTF { g_txtstyle_#2:n } { \cs_if_free:cTF { g_txtstyle_#1:n } { \cs_gset:cpn{g_txtstyle_#1:n} #2 } { \styledeferr:n{#1} } } { \stylenotdeferr:n{#1} } }

\NewDocumentCommand{\RenewTxtStyle}{mm} { \cs_if_exist:cTF { g_txtstyle_#1:n } { \DeclareTxtStyle {#1} {#2} } { \stylenotdefderr:n{#1} } }

\NewDocumentCommand{\ProvideTxtStyle}{mm} { \cs_if_exist:cF { g_txtstyle_#1:n } { \DeclareTxtStyle {#1} {#2} } }

% Sets the text style (similar to \bfseries, etc.) \NewDocumentEnvironment{TxtStyle}{m+b} { \cs_if_exist_use:cTF{g_txtstyle_#1:n} {{#2}} { \stylemissingerr:n{#1} } }{}

\NewDocumentCommand{\StyleTxt}{m+m} { \begin{TxtStyle}{#1} #2 \end{TxtStyle} }

main.tex

\documentclass{article}
\RequirePackage{txtstyles}

\begin{document}

\DeclareTxtStyle{sty}{large,red} \StyleTxt{sty}{This text} was styled. Done.

\end{document}