我想改变我写的表格的格式,使它类似于图中所示的表格。非常感谢大家。你能帮助我吗?非常感谢。
\documentclass[a4paper,12pt]{article}[12pt]
\usepackage[italian]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{anysize}
\usepackage{graphicx}
\usepackage{float}
\usepackage{etoolbox}
\usepackage{amsbsy}
\usepackage{amsmath}
\usepackage{pbox}
\usepackage{fancyhdr}
\usepackage{cancel}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{textcomp}
\linespread{1.5}
\frenchspacing
\newcommand{\abs}[1]{\lvert#1\rvert}
\usepackage{floatflt,epsfig}
\usepackage{multicol}
\usepackage[a4paper,top=1.0cm,bottom=1.0cm,left=1.0cm,right=1.0cm]{geometry}
\renewcommand{\rmdefault}{phv}
%\usepackage{mathpple}
%\usepackage{palatino}
\usepackage{lxfonts}
%
% \usepackage{multicol}
\usepackage{pifont}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{bbding}
\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}
\begin{table}[htbp]
\centering
% \caption{Add caption}
\begin{tabular}{c|c}
\toprule
$ c $ & \begin{flushleft}
$ y = 2\cdot a+1 $ \end{flushleft} \\
\midrule
$ 0 $ & $ 2\cdot \left( \ldots\ldots \right)+1 = \ldots\ldots =\ldots$ \\
$ +1 $ & $ 2\cdot \left( \ldots\ldots \right)+1 = \ldots\ldots =\ldots$ \\
$ +2 $ & $ 2\cdot \left( \ldots\ldots \right)+1 = \ldots\ldots =\ldots$\\
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
\end{document}
答案1
您可以使用它来对齐 =
\documentclass{article}
\usepackage{array}
\begin{document}
\renewcommand\arraystretch{1.5}
\begin{tabular}{>{$}c<{$}|*{3}{>{$}l<{$}@{\,$=$\,}}>{$}l<{$}}
a & y & \multicolumn{1}{@{}>{$}l<{$}@{}}{2\cdot a+1} & \multicolumn{2}{l}{} \\\hline
0 & \multicolumn{1}{l}{} & 2\cdot(0)+1 & \ldots & \ldots \\\hline
+1 & \multicolumn{1}{l}{} & 2\cdot(+1)+1 & \ldots & \ldots \\\hline
+2 & \multicolumn{1}{l}{} & 2\cdot(+2)+1 & \ldots & \ldots \\\hline
\end{tabular}
\end{document}
答案2
使用左对齐列(通过使用l
而不是c
)。我还删除了\left
和 ,\right
因为它们在这里不起作用。而且我认为一个\ldots
就足够了。
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{c|l}
\toprule
$ c $ & $ y = 2\cdot a+1 $ \\
\midrule
$ 0 $ & $ 2\cdot(\ldots)+1 = \ldots = \ldots$ \\
$ +1 $ & $ 2\cdot(\ldots)+1 = \ldots = \ldots$ \\
$ +2 $ & $ 2\cdot(\ldots)+1 = \ldots = \ldots$ \\
\bottomrule
\end{tabular}%
\end{document}
为了得到如图所示的效果,请使用arydshln
。然后稍微增加\arraystretch
一点。
\documentclass{article}
\usepackage{arydshln}
\begin{document}
\renewcommand\arraystretch{1.5}
\begin{tabular}{c|l}
$c$ & $y = 2\cdot a+1$ \\
\hline
$0$ & $2\cdot(\ldots)+1 = \ldots = \ldots$ \\
\hdashline
$+1$ & $2\cdot(\ldots)+1 = \ldots = \ldots$ \\
\hdashline
$+2$ & $2\cdot(\ldots)+1 = \ldots = \ldots$ \\
\hdashline
\end{tabular}
\end{document}