如何让表格和方程式保持在左侧?

如何让表格和方程式保持在左侧?
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
First find how many days between July 22 and Nov 4
    \[\begin{tabular}{|ccc|}
    \hline 
    Month &       & days \\
    \hline \hline
    July  &  31-22  & 9 \\
    August &       & 31 \\
    September &       & 30 \\
    October &&31\\
    November&&4\\
    \hline \hline
    \multicolumn{2}{|c}{total } & 105 days \\
    \hline
   \end{tabular}\]

\begin{flalign*} 
PV &= \frac{FV}{1+r \times t} \\\\
 &= \frac{1000}{\left(1+0.07 \times \frac{105}{365}\right)} \\\\
 &= \dfrac{2000}{1.020137}\\\\
 &= \$980.26
\end{flalign*}
\end{document}

我想让所有内容都保持在左侧,但是当前表格位于中央。

答案1

由于您已经在显示方程式内定义了一个表格(!),因此您可以将fleqn其用作选项documentclass

\documentclass[12pt,a4paper,fleqn]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\setlength\mathindent{0pt} %% reduce the indent for equations to 0pt.
\begin{document}
First find how many days between July 22 and Nov 4
    \[\begin{tabular}{|ccc|}
    \hline
    Month &       & days \\
    \hline \hline
    July  &  31-22  & 9 \\
    August &       & 31 \\
    September &       & 30 \\
    October &&31\\
    November&&4\\
    \hline \hline
    \multicolumn{2}{|c}{total } & 105 days \\
    \hline
   \end{tabular}\]

    \begin{flalign*}
PV &= \frac{FV}{1+r \times t} \\\\
 &= \frac{1000}{\left(1+0.07 \times \frac{105}{365}\right)} \\\\
 &= \dfrac{2000}{1.020137}\\\\
 &= \$980.26
\end{flalign*}
\end{document}

在此处输入图片描述

更新:

现在是时候以正确的方式做事了。tabular不需要在 内使用\[...\]。 正如 Gonzalo 所指出的,不必使用 double\\在方程式之间留出一些额外的垂直空间,而是可以使用可选参数,例如\\[<len>],其中<len>可以是\jot或任何长度单位,例如ptcm的倍数,baselineskip如本例所示,其中序言中没有任何变化:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}    
\begin{document}

First find how many days between July 22 and Nov 4
\par\noindent
\begin{tabular}{|ccc|}
    \hline
    Month &       & days \\
    \hline \hline
    July  &  31-22  & 9 \\
    August &       & 31 \\
    September &       & 30 \\
    October &&31\\
    November&&4\\
    \hline \hline
    \multicolumn{2}{|c}{total } & 105 days \\
    \hline
\end{tabular}
here
\begin{flalign*}
    PV  &= \frac{FV}{1+r \times t} && \\[\jot]
        &= \frac{1000}{\left(1+0.07 \times \dfrac{105}{365}\right)} && \\[.5cm]
        &= \dfrac{2000}{1.020137} && \\[\baselineskip] 
        &= \$980.26 &&
\end{flalign*}
\end{document}

答案2

如果你真的想要左对齐(这似乎不太好),那么你可以这样做:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
First find how many days between July 22 and Nov 4
\begin{flalign*}\settowidth{\dimen0}{$PV$}
  \makebox[\dimen0][l]{\begin{tabular}{|ccc|}
    \hline
    Month &   & days \\
    \hline \hline
    July  &  31-22  & 9 \\
    August &       & 31 \\
    September &       & 30 \\
    October &&31\\
    November&&4\\
    \hline \hline
    \multicolumn{2}{|c}{total } & 105 days \\
    \hline
 \end{tabular}}&&&\\[\jot]
PV &= \frac{FV}{1+r \times t} &&\\[\jot]
 &= \frac{1000}{\left(1+0.07 \times \frac{105}{365}\right)} &&\\[\jot]
 &= \frac{2000}{1.020137}&&\\[\jot]
 &= \$980.26&&\vphantom{\frac{\mathstrut}{\mathstrut}}
\end{flalign*}
\end{document}

设置tabular为具有等于“PV”的表观宽度。与其使用“空行”,不如留出少量空间(\jot,也可以是2\jots1.5\jots或任何其他,任您选择)。为了获得左对齐,您必须添加另一个“假”列,由最后的 表示&&

答案3

您已在显示方程式中使用表格。如果删除该表格,则表格将自动移至左侧。对于方程式,您可以在行末使用 && 将其移至左侧。以下是代码:

\documentclass[12pt,a4paper]{article}  
\usepackage[utf8]{inputenc}  
\usepackage{amsmath}  
\usepackage{amsfonts}  
\usepackage{amssymb}  
\usepackage{graphicx}  
\begin{document}  

First find how many days between July 22 and Nov 4\\\\  
   \begin{tabular}{|lll|}  
    \hline   
    Month &       & days \\   
    \hline \hline  
    July  &  31-22  & 9 \\  
    August &       & 31 \\  
    September &       & 30 \\  
    October &&31\\  
    November&&4\\  
    \hline \hline  
    \multicolumn{2}{|c}{total } & 105 days \\  
    \hline  
   \end{tabular}  
    \begin{flalign*}   
PV &= \frac{FV}{1+r \times t} && \\\\  
 &= \frac{1000}{\left(1+0.07 \times \frac{105}{365}\right)} && \\\\  
 &= \dfrac{2000}{1.020137} && \\\\  
 &= \$980.26 &&  
\end{flalign*}  
\end{document}  

希望这会有所帮助。

相关内容