0

I would like to create a table in which I have all the writings centered, both in row and in column.

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage{multirow} \usepackage{tabularx} \usepackage{booktabs} \newcolumntype{Y}{<{\centering\arraybackslash}X} \begin{document} \begin{table}[h] \caption{Elenco riassuntivo di tutte le perdite meccaniche} \label{Tab:tabellariassuntiva} {\centering\renewcommand\arraystretch{1.2} \begin{tabularx}{\textwidth}{@{}lYYYYY@{}} \toprule Componente & Valore & Formulazione utilizzata \\ \midrule \thead{Cuscinetto superiore \\ albero verticale U1847} & 650 & Bearing select SKF \\ \bottomrule \end{tabularx} } \end{table} \end{document} 
3
  • Adding \renewcommand\tabularxcolumn[1]{m{#1}} to the preamble of your document should result in the expected vertically centered alignment of the contents. Commented Oct 30, 2020 at 10:10
  • Why do you declare a total of 6 columns while you only seem to need 3 of them? Commented Oct 30, 2020 at 10:12
  • 1
    Welcome to TeX.SE! Commented Oct 30, 2020 at 10:13

1 Answer 1

3

Your MWE has two errors:

  • definition of Y column type have wrong sign <, it should be >
  • missing is package makecell

and defined to much columns (sufficient are 3 Y columns). Considering this:

\documentclass{article} \usepackage{booktabs, makecell, tabularx} % <--- \newcolumntype{Y}{>{\centering\arraybackslash}X} % <--- \begin{document} \begin{table}[h] \caption{Elenco riassuntivo di tutte le perdite meccaniche} \label{Tab:tabellariassuntiva} \centering\renewcommand\arraystretch{1.2} \begin{tabularx}{\textwidth}{@{} YYY @{}} % <--- \toprule Componente & Valore & Formulazione utilizzata \\ \midrule \makecell{Cuscinetto superiore\\ albero verticale U1847} & 650 & Bearing select SKF \\ \bottomrule \end{tabularx} \end{table} \end{document} 

the result of corrected code gives what you after:

enter image description here

The same result you can obtain with:

\documentclass{article} \usepackage{booktabs, tabularx} \newcolumntype{Y}{>{\centering\arraybackslash}X} % <--- \begin{document} \begin{table}[h] \renewcommand\tabularxcolumn[1]{m{#1}} % <--- \caption{Elenco riassuntivo di tutte le perdite meccaniche} \label{Tab:tabellariassuntiva} \centering\renewcommand\arraystretch{1.2} \begin{tabularx}{\textwidth}{@{} YYY @{}} \toprule Componente & Valore & Formulazione utilizzata \\ \midrule Cuscinetto superiore albero verticale U1847 & 650 & Bearing select SKF \\ \bottomrule \end{tabularx} \end{table} \end{document} 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.