표 2 열 문제: 위치가 잘못됨 \noalign

표 2 열 문제: 위치가 잘못됨 \noalign

이전에는 3개의 열을 사용하고 있었습니다. 2개의 열로 전환하고 모든 내용을 맞게 포맷했는데 테이블이 깨졌습니다.

문제를 해결할 방법을 찾을 수 없습니다. 문제를 찾고 해결하도록 도와줄 수 있는 사람이 있습니까?

재현 가능한 최소 예(Overleaf로 컴파일됨):

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

결과:

여기에 이미지 설명을 입력하세요

오류:

여기에 이미지 설명을 입력하세요

31: Misplaced \noalign
32: Extra alignment tab has been changed to \cr.

답변1

이 명령은 \centering{\textbf{Description}}오류 메시지를 생성합니다. 헤더 셀의 내용을 중앙에 배치하려는 타당한 이유를 찾을 수 없으므로 지시문을 제거하겠습니다 \centering. (어떤 이유로 오른쪽 머리글 셀의 내용을 중앙에 배치해야 하는 경우 \textbf{Description}간단히 \multicolumn{1}{c|}{\textbf{Description}}.

또한 설정으로 전환 tabularx하고 테이블의 목표 너비를 \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}

관련 정보