테이블 형식 환경에서 명령을 어떻게 단축할 수 있나요?

테이블 형식 환경에서 명령을 어떻게 단축할 수 있나요?

테이블은 다음과 같습니다.

\begin{tabular}{|>{\centering\arraybackslash}m{2cm}|>{\centering\arraybackslash}m{7cm}|>{\centering\arraybackslash}m{1cm}|}
        \hline
        \textbf{Keys} & \textbf{Description} & \textbf{Type}
\end{tabular}

어떻게든 명령을 짧게 하고 싶어요

**{|>{\centering\arraybackslash}m{2cm}|>{\centering\arraybackslash}m{7cm}|>{\centering\arraybackslash}m{1cm}|}**

와 같은 짧은 명령에 추가하므로 **\firststyle**항상 긴 문자열을 복사할 필요가 없습니다.

\begin{tabular} {\firststyle}
        \hline
        \textbf{Keys} & \textbf{Description} & \textbf{Type}
\end{tabular}

답변1

\newcolumntypefrom 패키지를 사용하면 array매개변수 유무에 관계없이 새 열 유형을 정의할 수 있습니다. 섹션 1.1을 참조하세요.패키지 문서.

\documentclass{article}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{A}{|M{2cm}|M{7cm}|M{1cm}|}

\begin{document}
You can define a column type with a parameter:

\begin{tabular}{|M{2cm}|M{7cm}|M{1cm}|}
        \hline
        \textbf{Keys} & \textbf{Description} & \textbf{Type}
\end{tabular}

You can even define a unique column type for all the columns of your table:

\documentclass{article}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{A}{|M{2cm}|M{7cm}|M{1cm}|}

\begin{document}
You can define a column type with a parameter:

\begin{tabular}{|M{2cm}|M{7cm}|M{1cm}|}
        \hline
        \textbf{Keys} & \textbf{Description} & \textbf{Type}
\end{tabular}

I don't know how much this is orthodox, but you can even define a unique column type for all the columns of your table:

\begin{tabular}{A}
        \hline
        \textbf{Keys} & \textbf{Description} & \textbf{Type}
\end{tabular}
\end{document}

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

관련 정보