Makecell: Déclarez l'alignement par défaut dans \ usepackage []

Oct 11 2020

Je souhaite charger le makecellpackage avec une option par défaut pour que toutes les \makecellcellules soient alignées à gauche par défaut. Que dois-je remplacer OPTIONSci-dessous pour faire de l'alignement à gauche le comportement par défaut des \makecellcellules?

\documentclass{report}
\usepackage[OPTIONS]{makecell}
\begin{document}
\begin{tabular}{cc}
  \makecell{Label \\ 1} & 1234 \\
  \makecell{Label \\ 2} & 5678
\end{tabular}
\end{document}

Je suis presque certain d'avoir déjà vu cela fait, mais après avoir joué un peu avec, je ne peux pas le comprendre, ni le trouver dans la documentation .

Réponses

2 leandriis Oct 11 2020 at 18:18

Autant que je puisse voir, makecelln'offre pas d'option pour modifier l'alignement par défaut de, \makecellmais vous pouvez l'utiliser \renewcommand\cellalign{<alignment here>}pour modifier globalement l'alignement par défaut à votre guise.

\documentclass{report}
\usepackage{makecell}
\renewcommand\cellalign{cl}
\begin{document}
\begin{tabular}{cc}
  \makecell{Label \\ 1} & 1234 \\
  \makecell{Label \\ 2} & 5678
\end{tabular}
\end{document}
jsbibra Oct 11 2020 at 12:58

Directement depuis le manuel de makecell vous pouvez utiliser t / b / c ou r / l / c / p dans les options

\documentclass{report}

\usepackage{tabu, booktabs}
\usepackage[]{makecell}
\begin{document}
\begin{tabular}{cc}
  \makecell[l]{Label \\ 1} & 1234 \\
  \makecell[tl]{Label \\ 2} & 5678\\
   \makecell[br]{Label \\ 3} & ABCDE
\end{tabular}
    

        \begin{tabu} to \textwidth {lXX}
            \toprule
            Head Col 1 & Head Col 2 & Head Col 3 \\
            \hline
            Data Col 1 & Data Col 2 & \makecell[l]{here is \\ my text \\ in the cell} \\
            \addlinespace
            Data Col 1 & Data Col 2 & \makecell[tl]{here is \\ my text \\ in the cell} \\
            \addlinespace
            Data Col 1 & Data Col 2 & \makecell[br]{here is \\ my text \\ in the cell} \\
            \bottomrule
        \end{tabu}

\end{document}