glallen01 / army-memorandum-class

A LaTeX class for memos.
GNU General Public License v3.0
20 stars 24 forks source link

portion marking #37

Open glallen01 opened 3 years ago

glallen01 commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

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