매크로를 xparse \SplitList 매크로로 확장

매크로를 xparse \SplitList 매크로로 확장

;환경 으로 분리된 인수 목록을 처리하는 매크로를 만드는 데 도움을 받았습니다 itemize. 이를 달성하기 위해 xparse사용되었습니다.

인수 목록을 매크로로 포장하려고 시도했지만 아무 일도 일어나지 않았습니다. 이 문제를 어떻게 해결할 수 있나요?

MWE:

\documentclass{article}
\usepackage{xparse}
\newcommand\insertitem[1]{\item #1}

% xparse-command I had help with
\NewDocumentCommand\myList{>{\SplitList{;}}m}
  {\vspace*{-\baselineskip}
    \begin{itemize}
      \ProcessList{#1}{ \insertitem }
    \end{itemize}
  }

\newcommand\someStuff{One; two; three}

\begin{document}

\myList{One; two; three}

Now trying to expand macro content

\myList{\someStuff}

\end{document}

결과 는 \myList{One; two; three}원하는 대로 itemized 목록입니다. 후자의 예는 \myList{\someStuff}작동하지 않습니다. 내 문제에 대한 해결책은 아마도 질문 어딘가에 있을 것이라고 생각합니다.ProcessList(xparse)의 여러 인수를 매크로로 전달합니다. 표로 사용할 결과, 하지만 현재는 어디에 있는지 이해할 수 없습니다...

편집: 매크로에 인수를 저장하는 용도는 기본적으로 내 삶을 좀 더 쉽게 만들기 위한 것입니다. 나는 내가 가르치는 과목의 진급 계획에 대한 템플릿 구조를 만들었습니다. 예를 들어 학생들이 계획된 기간 동안 달성해야 하는 원하는 주요 역량을 인쇄해야 합니다. 이러한 역량(및 그 이상)은 지저분한 longtable환경에 싸여 있고, 그 방법을 배울 시간이 있을 때 템플릿을 수업으로 만들 계획이므로 블록을 두는 것이 매우 편리할 것입니다. 문서의 시작 부분은 다음과 같습니다.

\maincompetences{Competence one; competence two, etc.}
\learninggoals{Main goal one; main goal two; etc.}

답변1

TeX는 인수를 흡수할 때 인수를 확장하지 않습니다. 따라서 두 번째 경우에 전달되는 인수는 세미콜론을 포함하지 않는다는 것 \SplitArgument입니다 .\someStuff

인수에서 첫 번째 토큰을 강제로 확장할 수도 있지만 이로 인해 다른 문제가 발생할 수 있습니다.

낮은 수준의 솔루션.

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\myList}{sm}
 {
  \begin{itemize}
  \IfBooleanTF{#1}
   {
    \holene_mylist:o { #2 } % expand the argument (once)
   }
   {
    \holene_mylist:n { #2 }
   }
   \end{itemize}
 }

\seq_new:N \l_holene_mylist_input_seq

\cs_new_protected:Npn \holene_mylist:n #1
 {
  \seq_set_split:Nnn \l_holene_mylist_input_seq { ; } { #1 }
  \seq_map_inline:Nn \l_holene_mylist_input_seq
   {
    \item ##1
   }
 }
\cs_generate_variant:Nn \holene_mylist:n { o }

\ExplSyntaxOff

\newcommand\someStuff{One; two; three}

\begin{document}

\myList{One; two; three}

Now trying to expand macro content

\myList*{\someStuff}

\end{document}

여기에 이미지 설명을 입력하세요

*-변형을 사용하여 인수를 확장할지 여부를 결정합니다.

관련 정보