![테이블 형식 환경 내에서 \@ifnextchar 확장 문제](https://rvso.com/image/305898/%ED%85%8C%EC%9D%B4%EB%B8%94%20%ED%98%95%EC%8B%9D%20%ED%99%98%EA%B2%BD%20%EB%82%B4%EC%97%90%EC%84%9C%20%5C%40ifnextchar%20%ED%99%95%EC%9E%A5%20%EB%AC%B8%EC%A0%9C.png)
다음 문자에 따라 테이블 형식 환경 내부 \hline
및 내부 로 확장되는 매크로를 정의하고 싶습니다 .\cline
\documentclass{standalone}
\makeatletter
\def\mycline[#1]{\cline{#1}}
\def\myline{\@ifnextchar[{\mycline}{\hline}} % Does not work. Either misplaced \noalign or \omit
\makeatother
\begin{document}
\begin{tabular}{cc}
a1 & a2 \\
\myline
b1 & b2 \\
\myline[1-2]
\end{tabular}
\end{document}
불행하게도 이로 인해 위치가 잘못 \noalign
되거나 \omit
(또는 둘 다) 발생합니다. \@ifnextchar
시간이 지나도 완전히 확장되지는 않는 것 같습니다 . 어떤 아이디어?
답변1
스캔 작업 방식으로 인해 \noalign
확장할 수 없는 명령(여기서는 \futurelet
에서 사용됨 \@ifnextchar
)이 새 정렬 셀을 시작하고 행을 삽입하기에는 너무 늦습니다.
그룹 내에서 선택적 인수를 검색해야 합니다 \noalign
.
\documentclass{standalone}
\makeatletter
\def\myline{%
\noalign\bgroup
\@ifnextchar[%
{\aftergroup\mycline\egroup}%
{\aftergroup\hline\egroup}%
}
\def\mycline[#1]{\cline{#1}}
\makeatother
\begin{document}
\begin{tabular}{cc}
a1 & a2 \\
\myline
b1 & b2 \\
\myline[1-1]
c1 & c2
\end{tabular}
\end{document}
왜 문제를 찾고 있습니까?;-)