在表格保持居中的情况下在单元格中换行

在表格保持居中的情况下在单元格中换行

根据反馈,以下是更新后的代码。文本现在换行,但格式仍为左侧,而不是居中。

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{float}
\usepackage{setspace}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[bottom]{footmisc}
\usepackage{geometry}
\usepackage{array}
\usepackage{enotez}
\let\footnote=\endnote
\geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }
\newcolumntype{M}[1]{%
    >{\raggedright\arraybackslash\hspace{0pt}}
    m{#1}
}
\doublespacing

\begin{document}

\begin{table}
\centering
\caption{Financial Literacy Questions (Big Three)}
\begin{tabular}{M{10cm}}
\hline
\hline
1) Suppose you had \$100 in a savings account and the interest rate was 2\% per year. After 5 years, how much do you think you would have in the account if you left the money to grow? \\
2) Imagine that the interest rate on your savings account was 1\% per year and inflation was 2\% per year. After 1 year, how much would you be able to buy with the money in this account? \\
3) Please tell me whether this statement is true or false. ``Buying a single company's stock usually provides a safer return than a stock mutual fund." \\
\hline
\hline
\end{tabular}
\raggedright
\begin{singlespace}
** indicates the correct answer \\
\end{singlespace}
\end{table}

我想包含一个位于页面中央的表格,其中的 1 列内有文本。我尝试了以下方法:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{float}
\usepackage{setspace}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[bottom]{footmisc}
\usepackage{geometry}
\usepackage{enotez}
\let\footnote=\endnote
 \geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }
\begin{table}[H]
\centering
\caption{Financial Literacy Questions (Big Three)}
\begin{tabular}{l}
\hline
\hline
1) Suppose you had \$100 in a savings account and the interest rate was 2\% per year. After 5 years, how much do you think you would have in the account if you left the money to grow? \\
2) Imagine that the interest rate on your savings account was 1\% per year and inflation was 2\% per year. After 1 year, how much would you be able to buy with the money in this account? \\
3) Please tell me whether this statement is true or false. ``Buying a single company's stock usually provides a safer return than a stock mutual fund." \\
\hline
\hline
\end{tabular}
\end{table}

然后我尝试了完全相同的操作,但使用固定的列宽。这只是将整个表格移到了左侧。有帮助吗?

答案1

在表格所在段落结束之前,从\centering到切换。在和之间放置一个空白行 或。\raggedright\par\end{tabular}\raggedright

也许我应该推荐threeparttable.sty。

答案2

你可以尝试10cm的长度

在此处输入图片描述

\documentclass{article}

\usepackage{array}%<-----------------------in preamble

\newcolumntype{M}[1]{%
    >{\raggedright\arraybackslash\hspace{0pt}}
    m{#1}
}
\begin{document}
\begin{table}
     \centering
    \caption{Financial Literacy Questions (Big Three)}
    \begin{tabular}{M{10cm}}
        \hline
        \hline
        1) Suppose you had \$100 in a savings account and the interest rate was 2\% per year. After 5 years, how much do you think you would have in the account if you left the money to grow? \\
        2) Imagine that the interest rate on your savings account was 1\% per year and inflation was 2\% per year. After 1 year, how much would you be able to buy with the money in this account? \\
        3) Please tell me whether this statement is true or false. ``Buying a single company's stock usually provides a safer return than a stock mutual fund." \\
        \hline
        \hline
    \end{tabular}
\end{table}
\end{document}

相关内容