
원본 게시물
다음은 제가 작업 중인 프로그램에 대해 최소한으로 작동하는 코드입니다. 내 문제는 더 복잡한 코드를 사용할 때 마지막에 자동으로 색인이 생성되지 않는다는 것입니다.
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{imakeidx} %allows for multiple indexes
\usepackage{xcolor}
\catcode`"=\active
\def"#1" {\textcolor{white}{#1}} %catcode to color words white, as to hide it on the the compile format
\catcode`@=\active
\def@[#1][#2][#3]@ {#2\index[#1]{$\square$ "#3" #2}} %catcode for FORMULAS that are sent to specific indexes as needed, here I use the catcode for "" in order to hide the letter that will allow for the index to be rearranged. so #3 will denote the order of the index, however it will be invisible to the naked eye on white paper so that the formula indexes are easier to read
%making indexes as needed
% \makeindex[name=NICKNAME, title={INDEX_TITLE},columns=1, intoc]
\makeindex[name=PV, title={Present Value},columns=1, intoc]
\usepackage{lipsum} %creating filler text for demonstration/test purposes
\begin{document}
@[PV][$PV$=summation $\frac{C}{(1+r)^n}$][c]@
\index[PV]{$\square PV = \sum \frac{C}{(1+r)^n}$}
@[PV][$PV = \sum \frac{C}{(1+r)^n}$][b]@
\indexprologue{Present Value is the discounted value, is the value of an expected income stream determined as of the date of valuation}
\printindex[PV]
\end{document}
색인에 무언가를 추가하기 위해 일반적인 입력을 수행하면 복잡한 공식이 다소 비슷한 형태로 나타납니다. 이는 아직 이상적이지 않습니다. 색인에 더 복잡한 수식을 입력할 수 있도록 \catcode를 더 잘 정의할 수 있는 방법이 있습니까?
업데이트된 코드
다음은 @barbara beeton 정보를 기반으로 업데이트된 코드입니다.
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{imakeidx} %allows for multiple indexes
%\usepackage{xcolor} no longer needed
%\catcode`"=\active
%\def"#1" {\textcolor{blue}{#1}} no longer need this as redefined the following catcode
\catcode`"=\active %changed symbol as @ is a seperator in makeidx
\def"[#1][#2][#3]" {#2\index[#1]{#3@$\square$ #2}} %catcode for FORMULAS that are sent to specific indexes as needed, #3 is used to take advantage of the fact that indexes are alphabetical to order the formulas in an organized manor. Ultimately this /catcode is used to print the #2 in the main text AND index #2 into the appropriate index, #1.
%making indexes as needed
% \makeindex[name=NICKNAME, title={INDEX_TITLE},columns=1, intoc]
\makeindex[name=PV, title={Present Value},columns=1, intoc]
\usepackage{lipsum} %creating filler text for demonstration/test purposes
\begin{document}
"[PV][$PV$= summation $\frac{C}{(1+r)^n}$][c]" %appears in index and maintext
\lipsum[2]
"[PV][$PV=\frac{C}{(1+r)^n}$][a]" %appears in index and main text
"[PV][$PV=\sum\frac{C}{(1+r)^n}$][b]" %appears in maintext BUT NOT IN INDEX
%this is what i want to appear in the index using the catcode
%\index[PV]{$\square PV=\sum\frac{C}{(1+r)^n}$}
\indexprologue{Present Value is the discounted value, is the value of an expected income stream determined as of the date of valuation}
\printindex[PV]
\end{document}
답변1
그래서 댓글을 통해 @barbara beeton이 문제를 발견할 수 있었습니다. 다른 사람들이 찾아서 해결할 수 있도록 답변을 게시하고 있습니다.
- 원본 코드의 구문 오류: 는 이미 발생한 문제와 필요 이상으로 복잡한 코드를 재정의하는
@
구분 기호입니다 .\makeidx
\catcode
해결책:"를 catcode 기호로 사용하십시오.
그 후에 파일은 오류 없이 컴파일되지만 색인에는 여전히 수식이 누락됩니다.
해결책
- 먼저 인덱스 로그 파일에서 해석되는 내용을 이해합니다.
.ilg
file은 오류가 있는지, 인덱스를 컴파일하는 과정에서 무시되는 것이 있는지 알려줍니다.오류가 있거나 항목이 거부되거나 무시되는 경우. 다음 단계로 이동. .idx
인덱스로 정확히 읽어지고 있음이 표시됩니다. 메모장과 같은 텍스트 파일 판독기에서 이것을 엽니다. 이렇게 하면 입력 내용이 어떻게 번역되고 색인으로 읽히는지 확인할 수 있어 문제가 있는 부분을 정확히 찾아내는 데 도움이 됩니다. 내 경우\sum
에는\DOTSB \sum@ \slimits@
.명령이 이상한 것으로 변환되는 경우 마지막 단계를 계속 진행하세요.\protect
명령이 다른 것으로 변환되는 것을 방지합니다. 따라서 이 경우 '$\sum\frac$은 이제 '\protect\sum \frac'이며 이제 복잡한 수식이 오류 없이 인덱스에 표시됩니다. 이는.idx
및 파일을 보면 확인할 수 있습니다.ilg
.
최종 코드
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{imakeidx} %allows for multiple indexes
\catcode`"=\active
\def"[#1][#2][#3]" {#2\index[#1]{#3@$\square$ #2}} %catcode for FORMULAS that are sent to specific indexes (defined by #1) as needed. #3 is used to take advantage of the fact that indexes are alphabetical to order the formulas in an organized manor. Ultimately this /catcode is used to automatically print the #2 in the main text AND index #2 into the appropriate index at the same time
%making indexes as needed
% \makeindex[name=NICKNAME, title={INDEX_TITLE},columns=1, intoc]
\makeindex[name=PV, title={Present Value},columns=1, intoc]
\begin{document}
%"[PV][$PV=\sum \frac{C}{(1+r)^n}$][b]" %appeared in maintext BUT NOT IN INDEX
"[PV][$PV=\protect\sum \frac{C}{(1+r)^n}$][b]" %appears in both index and main text
\indexprologue{Present Value is the discounted value, is the value of an expected income stream determined as of the date of valuation}
\printindex[PV]
\end{document}