文本垂直超出表格限制

文本垂直超出表格限制

我正在写表格,但有些行的文本超出了垂直限制。我该如何修复?谢谢。

这是我的代码:

\documentclass[a4paper,12pt]{article}[12pt] 
\usepackage{amsbsy}
\usepackage{amsmath}
\usepackage{pbox}
\usepackage{fancyhdr}
\usepackage{cancel}
\usepackage{tabularx} 
\usepackage{booktabs} 
\usepackage{multirow}
\usepackage{longtable} 
\usepackage{natbib} 
\usepackage{arydshln}
\usepackage{tikz}


\usepackage{subfig}                        

\usepackage{xcolor}
\usepackage{amsmath} 
\usepackage{amssymb}
\usepackage{mathrsfs} 

\linespread{1.5}    


\frenchspacing 

\newcommand{\abs}[1]{\lvert#1\rvert}



 \usepackage{multicol}



 \usepackage[a4paper,top=1.0cm,bottom=1.0cm,left=1.0cm,right=1.0cm]{geometry}


 \newcommand{\cuthere}{%
 \noindent
 \raisebox{-2.8pt}[0pt][0.75\baselineskip]{\small\ding{34}}
 \unskip{\tiny\dotfill}
 }

 \newcommand{\makenonemptybox}[2]{%
   \par\nobreak\vspace{\ht\strutbox}\noindent
   \fbox{%
     \parbox[c][\dimexpr#1-2\fboxsep][t]{\dimexpr\linewidth-2\fboxsep}{
       \hrule width \hsize height 0pt
       #2
     }%
   }%
   \par\vspace{\ht\strutbox}
 }


\begin{document}



\makenonemptybox{3.2in}{
\colorbox{white}{}
\noindent \textbf{}



\noindent\begin{minipage}{0.60\linewidth}
\begin{tabular}{c|l}
  $x$  & $y $                      \\
  \hline
   $\dfrac{1}{2}$  &  \\
    \hdashline
   $1$  & \\
    \hdashline  
  $\dfrac{3}{2}$  &  \\
\hdashline
\end{tabular}
 \end{minipage}%
\begin{minipage}{0.4\linewidth}
 \centering

 \includegraphics[width=1.0\linewidth]{image.pdf}
\end{minipage}


}

\end{document}






 \usepackage[a4paper, margin=1.0cm]{geometry}

  \newcommand{\cuthere}{%
  \noindent
  \raisebox{-2.8pt}[0pt][0.75\baselineskip]{\small\ding{34}}
  \unskip{\tiny\dotfill}
  }

  \newcommand{\makenonemptybox}[2]{%
    \par\nobreak\vspace{\ht\strutbox}\noindent
    \fbox{%
      \parbox[c][\dimexpr#1-2\fboxsep][t]{\dimexpr\linewidth-2\fboxsep}{
        \hrule width \hsize height 0pt
        #2
      }%
    }%
    \par\vspace{\ht\strutbox}
  }

  \usepackage{cellspace}
  \setlength{\cellspacetoplimit}{4pt}
  \setlength{\cellspacebottomlimit}{4pt}

 \begin{document}

 \makenonemptybox{3.2in}{
 \colorbox{white}{}
 \noindent \textbf{}

 \noindent\begin{minipage}{0.60\linewidth}
  \begin{tabular}{ >{$}Sc<{$}|l}
 $ x $  & $ y = 3x+2 $ \\
   \hline
 $\dfrac{1}{2}$  & $3 \cdot \dfrac{1}{2}  + 2$  \\
     \hdashline
   1 & \\
     \hdashline
  \dfrac{3}{2} \\
 \hdashline
 \end{tabular}
  \end{minipage}%
 \begin{minipage}{0.4\linewidth}
  \centering

  \includegraphics[width=1.0\linewidth]{image.pdf}
 \end{minipage}
 }

 \end{document}

答案1

带有包的解决方案cellspace,它使您能够定义在以字母为前缀的说明符的列中单元格顶部和底部的最小垂直间距S(或者C如果您加载siunitx,因为这个包已经S为其他目的定义了一种列类型)。

\documentclass[a4paper,12pt, demo]{article}[12pt]

\usepackage{amsbsy, amssymb}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{pbox}
\usepackage{fancyhdr}
\usepackage{cancel}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{natbib}
\usepackage{arydshln}
\usepackage{tikz}
\usepackage{subfig}
\usepackage{xcolor}

\linespread{1.5}

\frenchspacing

\newcommand{\abs}[1]{\lvert#1\rvert}

\usepackage{floatflt,epsfig}
 \usepackage{multicol}
 \usepackage[a4paper, margin=1.0cm]{geometry}

 \newcommand{\cuthere}{%
 \noindent
 \raisebox{-2.8pt}[0pt][0.75\baselineskip]{\small\ding{34}}
 \unskip{\tiny\dotfill}
 }

 \newcommand{\makenonemptybox}[2]{%
   \par\nobreak\vspace{\ht\strutbox}\noindent
   \fbox{%
     \parbox[c][\dimexpr#1-2\fboxsep][t]{\dimexpr\linewidth-2\fboxsep}{
       \hrule width \hsize height 0pt
       #2
     }%
   }%
   \par\vspace{\ht\strutbox}
 }

 \usepackage{cellspace}
 \setlength{\cellspacetoplimit}{4pt}
 \setlength{\cellspacebottomlimit}{4pt}

\begin{document}

\makenonemptybox{3.2in}{
\colorbox{white}{}
\noindent \textbf{}

\noindent\begin{minipage}{0.60\linewidth}
 \begin{tabular}{ >{$}Sc<{$}|l}
 x & y \\
  \hline
   \dfrac{1}{2} & \\
    \hdashline
  1 & \\
    \hdashline
 \dfrac{3}{2} \\
\hdashline
\end{tabular}
 \end{minipage}%
\begin{minipage}{0.4\linewidth}
 \centering

 \includegraphics[width=1.0\linewidth]{image.pdf}
\end{minipage}
}

\end{document} 

在此处输入图片描述

相关内容