如何调整表格以适应列大小?

如何调整表格以适应列大小?

在下面的代码中,表格缩放超出了边距。我想调整它,但不调整表格内文本的字体大小。

\newcommand{\CLASSINPUTbottomtextmargin}{25.4mm}
\newcommand{\CLASSINPUTtoptextmargin}{19.1mm}
\newcommand{\CLASSINPUToutersidemargin}{15.8mm}
\newcommand{\CLASSINPUTinnersidemargin}{17mm}
\setlength{\textfloatsep}{-5pt}
\documentclass[letterpaper,conference]{IEEEtran}


\usepackage{graphicx}
\usepackage{array,multirow,makecell}
\usepackage{forest}
\usetikzlibrary{shadows}

\makeatletter
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

\setcellgapes{1pt}
\makegapedcells
\newenvironment{multicases}[1]
{\let\@ifnextchar\new@ifnextchar \left\lbrace\def\arraystretch{1.2}% \array{@{}l*{#1}{@{\quad}l}@{}}} {\endarray\right.\kern-\nulldelimiterspace}

\title{The principal title: hello !}


\begin{document}
\maketitle
this is just a text.this is just a text.this is just a text.this is just a text.this is just   a text.this is just a text.this is just a text.this is just a text.this is just a text.this is  just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this   is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text. this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.


\begin{table}[h]
\begin{tabular}{|c|l|}
\hline
    \textbf{\textit{notation}} & \multicolumn{1}{c|}{\textbf{\textit{Designation}}} \\    \hline
    \textbf{1-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{2-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{3-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}    \\ \hline
    \textbf{4-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{5-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{1-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{2-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{3-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}    \\ \hline
    \textbf{4-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{5-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{1-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{2-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{3-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}    \\ \hline
    \textbf{4-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
    \textbf{5-this is just a text.}  & \textit{this is just a text.this is just a text.this is just a text.this is just a text.}   \\ \hline
\end{tabular}
\end{table}


\end{document}

谢谢

答案1

您可以使用tabularx

\newcommand{\CLASSINPUTbottomtextmargin}{25.4mm}
\newcommand{\CLASSINPUTtoptextmargin}{19.1mm}
\newcommand{\CLASSINPUToutersidemargin}{15.8mm}
\newcommand{\CLASSINPUTinnersidemargin}{17mm}
\setlength{\textfloatsep}{-5pt}
\documentclass[letterpaper,conference]{IEEEtran}


\usepackage{array}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{tabularx}

\setcellgapes{1pt}
\makegapedcells
% \newenvironment{multicases}[1]{\let\@ifnextchar\new@ifnextchar 
% \left\lbrace\def\arraystretch{1.2}% \array{@{}l*{#1}{@{\quad}l}@{}}}{\endarray\right.\kern-\nulldelimiterspace}

\title{The principal title: hello !}


\begin{document}
\maketitle
this is just a text.this is just a text.this is just a text.this is just a text.this is just   a text.this is just a text.this is just a text.this is just a text.this is just a text.this is  just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this   is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text. this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.


\begin{table}[h]
\begin{tabularx}{\linewidth}{|>{\bfseries}c|>{\itshape}X|}
\hline
    \textit{notation} &  \multicolumn{1}{c|}{\textbf{\textit{Designation}}} \\    \hline
    1-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    2-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    3-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.    \\ \hline
    4-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    5-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    1-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    2-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    3-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.    \\ \hline
    4-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    5-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    1-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    2-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    3-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.    \\ \hline
    4-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
    5-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text.   \\ \hline
\end{tabularx}
\end{table}


\end{document}

在此处输入图片描述

答案2

您也可以使用 tabular* 或 tabulary。

在此处输入图片描述

\newcommand{\CLASSINPUTbottomtextmargin}{25.4mm}
\newcommand{\CLASSINPUTtoptextmargin}{19.1mm}
\newcommand{\CLASSINPUToutersidemargin}{15.8mm}
\newcommand{\CLASSINPUTinnersidemargin}{17mm}
\setlength{\textfloatsep}{-5pt}
\documentclass[twocolumn]{article}

\usepackage{tabulary, caption}

\setlength{\extrarowheight}{1pt}

\title{The principal title: hello !}


\begin{document}
\maketitle
this is just a text.this is just a text.this is just a text.this is just a text.this is just   a text.this is just a text.this is just a text.this is just a text.this is just a text.this is  just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this   is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text. this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.this is just a text.


\begin{table}

\caption{Table with tabular*}

\begin{tabular*}{\columnwidth}{|@{\extracolsep{\fill}}>{\bfseries}c|>{\itshape}p{0.48\columnwidth}|}
\hline
    \itshape Notation & \multicolumn{1}{c|}{\bfseries Designation} \\    \hline
1-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
2-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
3-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
4-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
5-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
1-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
2-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
3-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
4-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
5-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline

\end{tabular*}
\end{table}

\begin{table}

\caption{Table with tabulary}
\begin{tabulary}{\columnwidth}{|>{\bfseries}c|>{\itshape}L|}

\hline
    \itshape Notation & \multicolumn{1}{c|}{\bfseries Designation} \\    \hline
1-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
2-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
3-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
4-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
5-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
1-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
2-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
3-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
4-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline
5-this is just a text.  & this is just a text.this is just a text.this is just a text.this is just a text. \\ \hline

\end{tabulary}
\end{table}


\end{document}

相关内容