我是 Latex 新手。我创建了一个表格。但是,它不是我所期望的。
我希望它居中且分隔良好,如下所示(此表格是在 MS Word 中构建的),
\begin{table}[htb] % <--- "here", "top", "bottom"
\centering
\setcellgapes{2pt}
\makegapedcells
\caption{Sample result of N. UzZaman and Mumit’s Bangla soundex table}
\begin{tabularx}{\linewidth}{@{} lcc @{}}
\toprule
\toprule
\makecell[lb]{Input}
& \makecell[b]{Encoded}
& \makecell[b]{Suggestion}\\
\midrule
\textbengali{খুমাড়} & kumar & \textbengali{কুমার}\\
\textbengali{পাসান} & pasan & \textbengali{পাষাণ}\\
\bottomrule
\bottomrule
\end{tabularx}
\label{table3}
\end{table}
由于文档太大,我无法在这里发布整个代码。我添加了我使用的以下软件包。
\usepackage{xcolor}
\usepackage{listings}
\usepackage{booktabs}
\usepackage{array}
\usepackage{float}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{polyglossia}
\usepackage{fontspec}
\setmainlanguage{english}
\setotherlanguage{bengali}
\newfontfamily\bengalifont[Script=Bengali]{Vrinda}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{makecell, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{amsmath}
答案1
测试以下内容:
\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs, makecell, tabularx}
\setcellgapes{2pt}
\makegapedcells
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\usepackage[skip=1ex]{caption}
\begin{document}
\begin{table}[htb]
\caption{Sample result of N. UzZaman and Mumit’s Bangla soundex table}
\begin{tabularx}{\linewidth}{LCC}
\toprule
\makecell[lb]{Input}
& \makecell[b]{Encoded}
& \makecell[b]{Suggestion}\\
\midrule
some bengali text %\textbengali{খুমাড়}
& kumar & some bengali text \\ %\textbengali{কুমার}\\
some bengali text %\textbengali{পাসান}
& pasan & some bengali text \\ %\textbengali{পাষাণ}\\
\bottomrule
\end{tabularx}
\label{table3}
\end{table}
\begin{table}[htb]
\centering
\caption{Sample result of N. UzZaman and Mumit’s Bangla soundex table}
\begin{tabular}{lcc}
\toprule
\makecell[lb]{Input}
& \makecell[b]{Encoded}
& \makecell[b]{Suggestion}\\
\midrule
some bengali text %\textbengali{খুমাড়}
& kumar & some bengali text \\ %\textbengali{কুমার}\\
some bengali text %\textbengali{পাসান}
& pasan & some bengali text \\ %\textbengali{পাষাণ}\\
\bottomrule
\end{tabular}
\label{table3}
\end{table}
\end{document}
它给:
正如您的问题下方的评论中所提到的,tabularx
应该至少有一个类型为X
或派生自的列,X
如上面的代码中所使用(L
,C
)。
离题:看看以下链接是否对您有帮助: