색인 생성에 도움이 되는 명령

색인 생성에 도움이 되는 명령

논문, 보고서, 서적 등 대용량 텍스트를 보다 쉽게 ​​색인화할 수 있는 방법을 갖고 싶습니다. 여기서 자동으로 수행할 수 있는 마법 도구를 요청하는 게시물을 많이 찾았습니다. 그리고 내가 댓글에서 깨달은 한, 기계가 그런 일을 할 수 있다고 믿는 사람은 아무도 없습니다.중요한우리를 위한 임무.

따라서 색인 작업을 용이하게 하는 가장 좋은 해결책은 적절한 개인 명령을 만드는 것입니다(지금까지는 잘 하지 못합니다...). 나는 적어도 다음을 하고 싶습니다:

  1. 텍스트에 색인된 단어를 인쇄하는 방법이 있습니다. 즉, 내용을 두 번 입력하는 것을 방지하는 것입니다.

    (some text) word \index{word} ...
    

    아래 방식으로 명령을 정의하면 \self원하는 것을 얻을 수 있습니다.

    \DeclareRobustCommand{\self}[1]{{#1}\index{#1}} %solves 1 
    
  2. 여러 번 반복되는 색인 단어 내부 항목에 대한 명령을 정의합니다. 예: '단어'를 반복하지 마세요.

    \index{word! entry1}, \index{word! entry1}, \index{word! entry1}...
    

아래 명령이 \sub이를 수행합니다.

    \DeclareRobustCommand{\sub}[1]{\texttt{#1}\index{Set subordinate!#1}} %solves2
  1. 2와 동일하지만 이제 명령은 텍스트의 일부에서 변수 정의를 사용해야 합니다(이전의 고정된 "단어"를 대체하기 위해). 그게 가능합니까? 아래 예의 "Especial" 섹션에 대한 시도를 참조하세요.

  2. \splex인덱스( ) 항목( n변수)을 여러 개로 분할하는 명령 \index{}? 예를 들어 makeindex사용할 때 같은 줄에 모든 항목을 인쇄하지 않으려면 . \index{Cramer, determinant, matrices}특히 항목 수가 달라지는 일반적인 경우를 가정하고 있기 때문에 명령 작성을 시작하는 방법을 모릅니다. 내 생각은 텍스트를 \splex{Cramer, determinant, matrices}생성하기 위해 사용하는 것입니다 .\index{Cramer} \index{determinant} \index{matrices}

인터넷의 다른 예에서 비슷한 명령을 찾았고 관심에 맞게 조정하고 있지만 일부는 여전히 알 수 없습니다. 아래 예에 있는 명령이 괜찮습니까? 아니면 개선/교체할 수 있습니까? 그리고 포인트 3과 4를 해결하는 방법은 무엇입니까?

\documentclass{article}
\usepackage{makeidx}
\makeindex
%\DeclareRobustCommand{\self}[1]{\texttt{#1}\index{#1}} %solves 1 but changes text style
\DeclareRobustCommand{\self}[1]{{#1}\index{#1}} %solves 1 
\DeclareRobustCommand{\sub}[1]{\texttt{#1}\index{Set subordinate!#1}} %solves2
\newcommand{\subdef}[2]{\index{\subd!#1}} %attempt to 3
\begin{document}
  Usefull \self{commands}.

   (some text) \sub{entry1}. 
   (some text)  \sub{entry2}. 

    \newpage
    \section{Especial *NOT WORKING*}
    \def\subd{especial}
     Something1  \subdef{entry1}. 
     Something2  \subdef{entry2}. 
\printindex
\end{document}

부록

개인 명령(기본 명령부터 복잡한 명령까지)을 만드는 방법을 배우는 데 도움이 되는 좋은 튜토리얼이 있다면 댓글에 링크를 게시해 주세요.

답변1

나는 포인트 3이 무엇을 얻고 있는지 완전히 이해하지 못합니다. 귀하의 명령은 2개의 인수를 지정하지만 정의에서는 하나만 사용하고 텍스트에 인수를 넣을 코드가 없습니다. 이 경우에는 이것이 필요하다고 생각했습니다. 그러나 내가 가장 잘 이해하는 바에 따르면 3이 문제를 해결한다고 생각합니다.

4는 원하는 측면에서 이해하기 더 간단합니다. 그러나 내 솔루션은 etoolbox.

\documentclass{article}
\usepackage{makeidx,etoolbox}
\makeindex
\DeclareRobustCommand{\self}[1]{{#1}\index{#1}}% solves 1
\DeclareRobustCommand{\sub}[1]{\texttt{#1}\index{Set subordinate!#1}}% solves2
\DeclareRobustCommand{\subdef}[1]{\texttt{#1}\index{\subd!#1}}% solves 3? (not sure I've understood the aim of 3)
% etoolbox manual p. 24
\newcommand\splex[1]{% solves 4
  \forcsvlist{\listadd\mylist}{#1}%
  \forlistloop{\index}{\mylist}}
\begin{document}
  Useful \self{commands}.

  (some text) \sub{entry1}.
  (some text)  \sub{entry2}.

  \section{Especial *WORKING*}
  \def\subd{especial}
  Something1  \subdef{entry1}.
  Something2  \subdef{entry2}.

  \section{Another test}
  \def\subd{another test}
  Something 3  \subdef{entry3}.
  Something 4 \subdef{entry4}.

  \section{Split commands}
  Nothing much to say.\splex{Cramer, determinant, matrices}

  \printindex
\end{document}

텍스트와 목록

관련 정보