
Anteriormente estaba usando 3 columnas. Cambié a 2 columnas, formateé todo para que encajara y la tabla se rompió.
No puedo encontrar una manera de solucionarlo, ¿alguien puede ayudarme a encontrar y resolver el problema?
Ejemplo mínimo reproducible(compilado al dorso):
\documentclass{article}
\usepackage{caption}
\usepackage{float}
\usepackage{array}
\newcolumntype{L}[1]{>{\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\renewcommand\arraystretch{1.5}
\author{mikyll}
\title{test}
\begin{document}
\maketitle
\section{Introduction}
\begin{table}[H]
\centering
\begin{tabular}{ |p{0.2\linewidth}|p{0.7\linewidth}| }
\hline
\centering{\textbf{Feature}} & \centering{\textbf{Description}}\\
\hline
CORS control & test\\
\hline
Rate Limiting & test \\
\hline
\end{tabular}
\caption{API Gateway Requirements.}
\label{tab:api-gateway-requirements}
\end{table}
\end{document}
Resultado:
Error:
31: Misplaced \noalign
32: Extra alignment tab has been changed to \cr.
Respuesta1
La instrucción \centering{\textbf{Description}}
crea el mensaje de error. Como no veo una buena razón para querer centrar el contenido de las celdas del encabezado, me desharía de las \centering
directivas. (Si, por alguna razón, simplemente debe centrar el contenido de la celda del encabezado derecho, simplemente reemplácelo \textbf{Description}
con \multicolumn{1}{c|}{\textbf{Description}}
.
También cambiaría a una tabularx
configuración y establecería el ancho objetivo de la tabla en \textwidth
.
\documentclass{article}
\usepackage{tabularx,ragged2e}
\usepackage{caption}
\begin{document}
\begin{table}[htb]
\setlength\extrarowheight{2pt} % for a less-cramped look
\begin{tabularx}{\textwidth}{ |
>{\RaggedRight}p{0.2\linewidth} | % suppress full justification
>{\RaggedRight}X | } % suppress full justification
\hline
\textbf{Feature} & \textbf{Description} \\
\hline
CORS control & test \\
\hline
Rate Limiting & test \\
\hline
\end{tabularx}
\caption{API Gateway Requirements.}
\label{tab:api-gateway-requirements}
\end{table}
\end{document}