.png)
Intenté usar varias columnas para centrar la primera fila de la tabla y el resto sigue la regla de párrafo normal. Aquí está el fragmento de código:
\documentclass[a4paper,12pt]{report}
\usepackage{indentfirst}
\setlength{\parindent}{2.30em}
\usepackage[utf8]{inputenc}
\usepackage{pdflscape}
\usepackage{lscape}
\usepackage{booktabs, tabularx}
\usepackage{bm}
\usepackage{xfrac}
\usepackage[titles]{tocloft}
\usepackage{subfig}
\usepackage{rotating}
\usepackage{wrapfig}
\usepackage{mathptmx}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{cleveref}
\usepackage[top=1.8in, bottom=1.25in, left=1.75in, right=1.25in, headheight=1.25in]{geometry}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\sloppy
\microtypecontext{spacing=nonfrench}
\emergencystretch=\maxdimen
% Fonts
\usepackage{sectsty}
\allsectionsfont{\normalsize}
%Pagination
\usepackage{fancyhdr}
\pagestyle{fancyplain}% <- use fancyplain instead fancy
\fancyhf{}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
% Caption
\usepackage{caption}
\captionsetup{format=hang, font=normalsize, labelfont=bf, justification=justified, labelsep=period}
% Graphics
\usepackage{graphicx}
\graphicspath{{./Figure/}}
\DeclareGraphicsExtensions{.pdf,.jpeg,.jpg,.png}
% Spacing
\usepackage{setspace} % control linespacing
\setstretch{1.5}
\clearpage
\begin{document}
\renewcommand{\thechapter}{\Roman{chapter}}
\chapter{Methodology}
\renewcommand{\thechapter}{\arabic{chapter}}
\label{ch:Methodology}
\thispagestyle{empty}
\begin{landscape}
\centering
\begin{tabularx}{\linewidth}{| p{0.75in} | p{1in} | p{0.9in} | p{2in} | p{0.8in} | p{0.6in} | p{0.8in} |}{\hyphenpenalty=20\exhyphenpenalty=20}
\hline
\multicolumn{1}{|c|}{\textbf{Name}} & \multicolumn{1}{|c|}{\textbf{Alphanumeric Name}} & \multicolumn{1}{|c|}{\textbf{Fiber Strand Size}} (mm) &
\multicolumn{1}{|c|}{\textbf{Color}} & \multicolumn{1}{|c|}{\textbf{Stripping}} & \multicolumn{1}{|c|}{\textbf{Texture}} &
\multicolumn{1}{|c|}{\textbf{Extracted From}} \\
\hline
Streaky Two & S2 & 0.20 - 0.50 & Ivory white, slightly tinged with very light brown to red or purple streak & Excellent & Soft &
Next to the outer leafsheath \\
\hline
\end{tabularx}
\label{table:Abaca Fiber Grades}
\end{landscape}
\end{document}
Sin embargo, recibo los siguientes errores en la línea \end{tabularx}
:
¿Cómo elimino esos errores? No entiendo qué intenta decir el error. Su ayuda es muy apreciada. ¡Gracias!
Respuesta1
Una tabularx
tabla tipodebetenga al menos una X
columna de tipo para que el ancho total de la tabla tenga alguna posibilidad de ser igual al ancho objetivo. Además, debido a que está encerrando todas y cada una de las celdas del encabezado en un \multicolumn{1}{c}
contenedor, en realidad está deshabilitando el salto de línea en las celdas del encabezado, lo que da como resultado una tabla demasiado ancha. Mi consejo sería no utilizar los envoltorios y no utilizarnegritacualquiera. Ah, y por supuesto, deshazte de él {\hyphenpenalty=20\exhyphenpenalty=20}
.
Además, me gustaría animarte a que le des a la mesa un "aspecto" más abierto y atractivo, eliminando todas las reglas verticales y utilizando reglas horizontales bien espaciadas. Consulte la siguiente captura de pantalla para ver una comparación de la ventana de la celda de la prisión y el aspecto abierto y atractivo.
\documentclass[a4paper,12pt]{report}
\usepackage{indentfirst}
\setlength{\parindent}{2.30em} % that's kind of extreme
%\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage{pdflscape}
%\usepackage{lscape} %% don't load both lscape and pdflscape
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage{tabularx}
\usepackage{bm}
\usepackage{xfrac}
\usepackage[titles]{tocloft}
\usepackage{subfig}
%%\usepackage{rotating} %% do you need this package?
\usepackage{wrapfig}
\usepackage{amsmath, amssymb} % 'amsfonts' is loaded automatically by 'amssymb'
%\usepackage{mathptmx} % mathptmx is borderline obsolete
\usepackage{newtxtext,newtxmath}
\usepackage{cleveref}
\usepackage[top=1.8in, bottom=1.25in,
left=1.75in, right=1.25in,
headheight=1.25in % this seems excessive
]{geometry}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\microtypecontext{spacing=nonfrench}
%%\sloppy %% <-- a bad idea
%%\emergencystretch=\maxdimen
% Modify styles of sectioning headers
\usepackage{sectsty}
\allsectionsfont{\normalsize}
%Apperance of pages
\usepackage{fancyhdr}
\pagestyle{fancyplain}% <- use fancyplain instead fancy
\fancyhf{}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
% Caption
\usepackage{caption}
\captionsetup{format=hang,
font=normalsize,
labelfont=bf,
justification=justified,
labelsep=period,
skip=0.333\baselineskip}
% Graphics
\usepackage{graphicx}
\graphicspath{{./Figure/}}
\DeclareGraphicsExtensions{.pdf,.jpeg,.jpg,.png}
% Spacing
\usepackage{setspace} % control linespacing
\setstretch{1.5}
%%\clearpage % <-- not needed
%% New
\usepackage{ragged2e} % for '\RaggedRight' macro
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}} % get rid of full justification, allow hyphenation
\newcolumntype{L}{>{\RaggedRight}X} % ditto
\usepackage{calc} % for '\widthof' macro
\begin{document}
% \renewcommand{\thechapter}{\Roman{chapter}}
% \chapter{Methodology}
% \label{ch:Methodology}
%
% \renewcommand{\thechapter}{\arabic{chapter}}
%
% \thispagestyle{empty}
\begin{landscape}
%%\centering % no need for this
\begin{table}
\caption{Abaca Fiber Grades}
\label{table:Abaca_Fiber_Grades}
\begin{tabularx}{\linewidth}%
{| P{\widthof{Streaky Two}} |
P{\widthof{Alphanumeric}} |
P{\widthof{Fiber strand}} |
L |
P{\widthof{Excellent}} |
P{\widthof{Texture}} |
P{1.1in} |}
%\hyphenpenalty=20\exhyphenpenalty=20 % huh??
\hline
Name &
Alphanumeric name &
Fiber strand size (mm) &
Color &
Stripping & % 'Stripping' or 'Striping'?
Texture &
Extracted from \\
\hline
Streaky Two &
S2 &
0.20--0.50 &
Ivory white, slightly tinged with very light brown to red or purple streak &
Excellent &
Soft &
Next to the outer leafsheath \\
\hline
\end{tabularx}
\vspace*{1.5cm}
\caption{Same table, but (i) without vertical rules and (ii) with well-spaced horizontal rules}
\begin{tabularx}{\linewidth}%
{@{} P{\widthof{Streaky Two}}
P{\widthof{Alphanumeric}}
P{\widthof{Fiber strand}}
L
P{\widthof{Excellent}}
P{\widthof{Texture}}
P{1.1in} @{}}
%\hyphenpenalty=20\exhyphenpenalty=20 % huh?
\toprule
Name &
Alphanumeric name &
Fiber strand size (mm) &
Color &
Stripping & % 'Stripping' or 'Striping'?
Texture &
Extracted from \\
\midrule
Streaky Two &
S2 &
0.20--0.50 &
Ivory white, slightly tinged with very light brown to red or purple streak &
Excellent &
Soft &
Next to the outer leafsheath \\
\bottomrule
\end{tabularx}
\end{table}
\end{landscape}
\end{document}