Como posso encurtar os comandos em ambiente tabular?

Como posso encurtar os comandos em ambiente tabular?

A tabela é listada como segue.

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

Eu quero de alguma forma encurtar os comandos

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

em algum comando curto como **\firststyle**, então não preciso copiar strings longas o tempo todo.

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

Responder1

Com o pacote \newcolumntypefrom array, você pode definir um novo tipo de coluna, com ou sem parâmetros. Consulte a Seção 1.1 dodocumentação do pacote.

\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}

insira a descrição da imagem aqui

informação relacionada