表形式の環境でコマンドを短縮するにはどうすればよいですか?

表形式の環境でコマンドを短縮するにはどうすればよいですか?

表は以下のとおりです。

\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

から\newcolumntypearray、パラメータの有無にかかわらず、新しい列タイプを定義できます。パッケージドキュメント

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

ここに画像の説明を入力してください

関連情報