불균형 중괄호(`{` 및 `}`)를 표 형식 열로 리디렉션할 수 있나요?

불균형 중괄호(`{` 및 `}`)를 표 형식 열로 리디렉션할 수 있나요?

이 질문은 내 질문에 대한 후속 조치입니다.이전 질문:

셀 내용의 양쪽에 여는 중괄호와 닫는 중괄호를 사용 >하고 연결하는 것이 가능합니까 ? <좀 더 구체적으로 말하면 다음 열을 정의하고 싶습니다.

\newcolumntype{P}{>{\leavevmode\kern-\tabcolsep\bfseries\parbox[t]{\hsize}{}X<{}}}

.\parbox

나는 짧은 MNWE를 동봉합니다:

\documentclass[table]{article}
\usepackage{lmodern, microtype, xcolor, tabularx, tabulary}

\begin{document}

\begin{tabularx}{0.5\columnwidth}{>{\raggedright\arraybackslash\leavevmode\kern-\tabcolsep\parbox[t]{\hsize}{ }X<{}}XX<{\leavevmode\kern-\tabcolsep\raggedleft\arraybackslash}}

\rowcolor{lightgray}All this testing is not so funny&test&test\\\hline
testing, testing and even more testing &test&test\\
\rowcolor{lightgray}I want to write a noce table in a simple way&test&test\\
\end{tabularx}

\end{document}

답변1

버팀대를 덮는 >{}것은 <{}예상보다 어려워 보입니다. 명시적인 중괄호 토큰을 사용하는 방법을 생각해낼 수 없습니다. 다음은 TeX의 구분된 인수를 사용하는 대체 솔루션입니다. 직접 사용하는 대신 이를 래핑하는 \parbox도우미 매크로를 정의합니다 \parboxx ... \endparboxx. 그런 다음 이 매크로는 새 열 유형에서 사용됩니다 P.

\documentclass[table]{article}
\usepackage{lmodern, microtype, xcolor, tabularx, tabulary}

\begin{document}

\def\parboxx#1\endparboxx{\parbox[t]{\hsize}{\raggedright#1}}

\newcolumntype{P}{>{\leavevmode\kern-\tabcolsep\bfseries\parboxx}X<{\endparboxx}}

\begin{tabularx}{0.5\columnwidth}{PXX<{\leavevmode\kern-\tabcolsep\raggedleft\arraybackslash}}

\rowcolor{lightgray}All this testing is not so funny&test&test\\\hline
testing, testing and even more testing &test&test\\
\rowcolor{lightgray}I want to write a noce table in a simple way&test&test\\
\end{tabularx}

\end{document}

출력

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

관련 정보