![设置为表格内容居中](https://linux22.com/image/402854/%E8%AE%BE%E7%BD%AE%E4%B8%BA%E8%A1%A8%E6%A0%BC%E5%86%85%E5%AE%B9%E5%B1%85%E4%B8%AD.png)
我是乳胶的新手,我对表格元素有很大的困难,我正在用这个代码构建表格
\begin{table}[ht]
\centering\small
\caption{Specifications of LTE\label{tab:table1}}
\begin{tabularx}{\linewidth}{lX}
\toprule
Block\\
\midrule
Prova di lavoro (nonce) \\
Transazioni valide \\
Timestamp \\
Merkle Tree \\
\bottomrule
\end{tabularx}
\end{table}
我有这种效果
但我想让表格的内容位于上下文的中心,这样可以吗?
这是一个可重现的最小示例
\documentclass[12pt]{toptesi}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage{graphicx,wrapfig}
\usepackage{booktabs}
\usepackage{lmodern}
\usepackage{varioref}
\usepackage{url}
\usepackage{array}
\usepackage{paralist}{\obeyspaces\global\let =\space}
\usepackage{verbatim}
\usepackage{subfig}
\usepackage{tabularx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{float}
\usepackage{amssymb}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{listings}
\usepackage[pass]{geometry}
\usepackage[figuresright]{rotating}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{amsmath}
\usepackage[babel]{csquotes}
\usepackage{hyperref}
\usepackage[backend=bibtex]{biblatex}
\usepackage{xcolor}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{tabularx}
\usepackage{booktabs} % this package promotes good tabular style
\usepackage{caption} % for customising caption style
\usepackage{siunitx}
\begin{document}
\begin{table}[ht]
\centering\small
\caption{Specifications of LTE\label{tab:table1}}
\begin{tabularx}{\linewidth}{lX}
\toprule
Block\\
\midrule
Prova di lavoro (nonce) \\
Transazioni valide \\
Timestamp \\
Merkle Tree \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
另外,我希望标题位于底部位置,正确的设置是什么?
答案1
tabularx
如果你不想让表格和行一样宽,就不需要使用。一个简单的tabular
方法也可以达到目的:
\documentclass[12pt]{toptesi}
\usepackage{booktabs}
\usepackage{caption}
\begin{document}
\begin{table}[ht]
\centering\small
\caption{Specifications of LTE\label{tab:table1}}
\begin{tabular}{l}
\toprule
Block\\
\midrule
Prova di lavoro (nonce) \\
Transazioni valide \\
Timestamp \\
Merkle Tree \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
这是相当延伸的评论。你喜欢以下内容吗?
上表的 MWE(最小工作示例;一个重现您的问题的小而完整的文档)如下:
\documentclass[12pt]{article}%{toptesi}
\usepackage{booktabs, tabularx}
\usepackage{caption} % for customising caption style
\begin{document}
\begin{table}[ht]
\centering
\begin{tabularx}{\linewidth}{>{\centering\arraybackslash}X}
\toprule
Block \\
\midrule
Prova di lavoro (nonce) \\
Transazioni valide \\
Timestamp \\
Merkle Tree \\
\bottomrule
\end{tabularx}
\caption{Specifications of LTE}
\label{tab:table1}
\end{table}
\end{document}
注意,您在前言中加载了许多软件包两次。请清理前言。此时问问自己,您真的需要所有这些软件包吗?