Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

portion marking #37

Open
glallen01 opened this issue Apr 18, 2021 · 2 comments
Open

portion marking #37

glallen01 opened this issue Apr 18, 2021 · 2 comments

Comments

@glallen01
Copy link
Owner

re #36

comments moved from PR to issue:

also something like the following could work for formatting:

\documentclass{scrartcl}
\usepackage{enumitem}
\usepackage{xparse}

\NewDocumentCommand{\eitem}{ o o }{
  \IfNoValueTF{#2}{%
    \IfNoValueTF{#1}{ \item (U)     }{ \item (#1)   }%
  }{%
    \IfNoValueTF{#1}{ \item[#2] (U) }{ \item[#2] #1 }%
  }
}

\begin{document}
\begin{enumerate}
  \eitem This should be (U).
  \eitem This should be (U).
  \eitem[A] This should be (A).
  \eitem[D//E] This should be (D//E).
  \eitem[(D)][3.] This should be 3. (D).
  \eitem[(E)][99.] This should be 99. (E).
\end{enumerate}
\end{document}

producing (with slight spacing issues):

1. (U) This should be (U).
2. (U) This should be (U).
3. (A) This should be (A).
4. (D//E) This should be (D//E).
3. (D) This should be 3. (D).
99. (E) This should be 99. (E).

It would be nice to figure out how to redefine \item itself to make it easier on the user. It's a little tricky because I'd want the class to be the first optional argument before the item number. But I'll have to figure out how to make the \@ifnextchar [ check for optional args work for multiple arguments? rewrite that as xparse, or dig into \@item...

$ texdef -t latex -f item

\item is defined by (La)TeX.

\item:
macro:->\@inmatherr \item \@ifnextchar [\@item {\@noitemargtrue \@item [\@itemlabel ]}

$ texdef -t latex -f \@item

\@item is defined by (La)TeX.

\@item:
macro:[#1]->\if@noparitem \@donoparitem \else \if@inlabel \indent \par \fi \ifhmode \unskip \unskip \par \fi \if@newlist \if@nobreak \@nbitem \else \addpenalty \@beginparpenalty \addvspace \@topsep \addvspace {-\parskip }\fi \else \addpenalty \@itempenalty \addvspace \itemsep \fi \global \@inlabeltrue \fi \everypar {\@minipagefalse \global \@newlistfalse \if@inlabel \global \@inlabelfalse {\setbox \z@ \lastbox \ifvoid \z@ \kern -\itemindent \fi }\box \@labels \penalty \z@ \fi \if@nobreak \@nobreakfalse \clubpenalty \@M \else \clubpenalty \@clubpenalty \everypar {}\fi }\if@noitemarg \@noitemargfalse \if@nmbrlist \refstepcounter \@listctr \fi \fi \sbox \@tempboxa {\makelabel {#1}}\global \setbox \@labels \hbox {\unhbox \@labels \hskip \itemindent \hskip -\labelwidth \hskip -\labelsep \ifdim \wd \@tempboxa >\labelwidth \box \@tempboxa \else \hbox to\labelwidth {\unhbox \@tempboxa }\fi \hskip \labelsep }\ignorespaces

Potentially useful references:

@glallen01
Copy link
Owner Author

Based on https://www.latex-project.org/help/documentation/lthooks-doc.pdf, this may be a much better approach.

\makeatletter
\let\@markitem\item%
\newcommand*{\setdefaultportionmark}[1]{\AddToHook{cmd/item/after}{(#1)~}}
\newcommand*{\markitem}[1]{\@markitem (#1)}
\makeatother

\setdefaultportionmark{U}
% and then override as needed with
\markitem{XXX}

@glallen01
Copy link
Owner Author

https://www.texnology.com/talk2.pdf ref use of \csname for tracking highest class per page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant