早上好/下午好/晚上好
我得到了下面的源代码。结果在左边的图片上。为什么标记(黑色圆圈)在表格下方?如何修复它?我希望标记位于表格旁边 - 顶部或中间(在同一层)。
我不得不用桌子前表格因为编译器给了我一个错误信息,如右图所示。我读过这个论坛上的一些文字,他们的建议是使用table
。但问题仍然存在。如何修复它?
谢谢你的帮助。
\documentclass[10pt,a6paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper, top=10mm, left=10mm, right=10mm,
bottom=10mm,foot=5mm,marginparsep=0mm,showframe]{geometry}
\usepackage{tipa}
\usepackage{tabularx,booktabs}
\usepackage{multirow}
\begin{document}
\begin{itemize}
\item some text
\item
\begin{table}[h!]
\centering
\begin{tabular}{l l}
& {\multicolumn{1}{c}{Otázka}} \\
& {\multicolumn{1}{c}{\sffamily{Question}}} \\
\toprule
\sffamily{I am \ldots .} & \sffamily{Am I \ldots ?}\\
\sffamily{You are \ldots .} & \sffamily{Are you \ldots ?}\\
\sffamily{He is \ldots .} & \sffamily{Is he \ldots ?}\\
\sffamily{She is \ldots .} & \sffamily{Is she \dots ?}\\
\sffamily{It is \ldots .} & \sffamily{Is it \ldots ?}\\
\sffamily{We are \ldots .} & \sffamily{Are we \ldots ?}\\
\sffamily{You are \ldots .} & \sffamily{Are you \ldots ?}\\
\sffamily{They are \ldots .} & \sffamily{Are they \ldots ?}\\
\bottomrule
\end{tabular}
\end{table
\item some text
\end{itemize}
\end{document}
答案1
在table
环境中,居中是根据线宽而不是分配给项目内容的宽度进行的。要在第二种情况下居中,可以使用minipage
调整宽度的。比较:
\documentclass[10pt,a6paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper,
top=10mm, left=10mm, right=10mm,
bottom=10mm, foot=5mm, marginparsep=0mm,
showframe]{geometry}
\usepackage{tipa}
\usepackage{tabularx,booktabs}
\usepackage{multirow}
\usepackage{caption} %
\begin{document}
\begin{itemize}
\item some text some text some text some text some text some text some text some text
\item %
\begin{minipage}[t]{\dimexpr\linewidth-\itemindent\relax}\centering
\begin{tabular}[t]{>{\sffamily}l >{\sffamily}l}
& \multicolumn{1}{c}{Otázka} \\
& \multicolumn{1}{c}{\sffamily{Question}} \\
\toprule
I am \ldots & Am I \ldots ?\\
You are \ldots & Are you \ldots ?\\
He is \ldots & Is he \ldots ?\\
She is \ldots & Is she \dots ?\\
It is \ldots & Is it \ldots ?\\
We are \ldots & Are we \ldots ?\\
You are \ldots & Are you \ldots ?\\
They are \ldots & Are they \ldots ?\\
\bottomrule
\end{tabular}
\captionof{table}{Some caption}
\end{minipage}
\\
\item %
\leavevmode\vspace*{-\dimexpr\baselineskip+\topsep\relax}
\begin{table}[!h]
\centering
\begin{tabular}[t]{>{\sffamily}l >{\sffamily}l}
& \multicolumn{1}{c}{Otázka} \\
& \multicolumn{1}{c}{\sffamily{Question}} \\
\toprule
I am \ldots & Am I \ldots ?\\
You are \ldots & Are you \ldots ?\\
He is \ldots & Is he \ldots ?\\
She is \ldots & Is she \dots ?\\
It is \ldots & Is it \ldots ?\\
We are \ldots & Are we \ldots ?\\
You are \ldots & Are you \ldots ?\\
They are \ldots & Are they \ldots ?\\
\bottomrule
\end{tabular}
\caption{Some caption}
\end{table}
\end{itemize}
\end{document}