**第二次编辑:我更改了标题以确保不会让任何人感到困惑。看到大家的评论后,我意识到我在哪里感到困惑。
- *制作所有文本的有效方法是什么
"\flushleft"
?问题解决了。感谢@koleygr(参见第一个答案,评论 1) - *有什么有效的方法来“设置”表格中的所有元素的样式,而不是单独设置它们?问题解决了。同上(评论 2)。
- *创建多条新行的有效方法是什么?问题解决了。同上(评论 3)。还有更多问题需要解决:
- 我如何知道有多少英寸或厘米
\vspace
?有经验吗? - 当我写的时候
\documentclass[12pt]{article}
,字体大小和 M$ Word 中的字体大小不同吗?因为我是根据教授给我的文档重新设计轮子,但字体大小并不完全相同。 - 如果里面
\(\)
有一些我不想用斜体显示的文字,我\text{}
每次都必须写吗?
大家好!我这个学期结束后就要上大学了。我是数学专业的,我想提前学习 LaTeX。我已经学习 LaTeX 有一段时间了,这是我第一次用 LaTeX 写经济学作业。
你们觉得这段代码怎么样?有什么需要改进的吗?
我在写作时注意到的一件事是,我创建的表格与上面的其他文本相比略有偏移。有什么办法可以解决这个问题吗?
向大家致以最良好的祝愿。
这是我的代码:
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{mathptmx}
\begin{document}
\begin{flushleft}
\section*{\small \bfseries First Economic Assignment: GDP Deflator}
\subsection*{\small \bfseries Consumer Spending}
\begin{tabular}{l c c c c c}
\small \bfseries Goods/Services & \small \bfseries 2017 Quantity & \small \bfseries 2017 Price & \small \bfseries 2016 Quantity & \small \bfseries 2016 Price\\
\small Sushi & \small 625,000 & \small \$30.00 & \small 600,000 & \small \$28.00\\
\small Jamba Juice & \small 750,000 & \small \$5.35 & \small 700,000 & \small \$5.00\\
\small Samsung 4k Television & \small 50,000 & \small \$799.99 & \small 45,000 & \small \$749.99\\
\small Samsung Note 8 & \small 125,000 & \small\$199.99 & \small 100,000 & \small \$189.99
\end{tabular}
\newline \newline
\small Calculate the Nominal GDP for 2017.\\
\(\text{Norminal GDP}_{cs2017} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2017}} = 625,000 \times \$30.00+750,000 \times \$5.35+50,000 \times\$799.99+125,000 \times\$199.99 = \textbf{87,760,750}\)
\newline
\small Calculate the Real GDP with a base year of 2016.\\
\(\text{Real GDP}_{cs2016} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2016}} = 625,000 \times \$28.00+750,000 \times \$5.00+50,000 \times \$749.99+125,000 \times \$189.99 = \textbf{82,498,250}\)
\subsection*{\small \bfseries Government Spending}
\begin{tabular}{l c c c c c}
\small \bfseries Goods/Services & \small \bfseries 2017 Quantity & \small \bfseries 2017 Price & \small \bfseries 2016 Quantity & \small \bfseries 2016 Price\\
\small Public Schools & \small 1,000 & \small \$300 m & \small 950 & \small \$280 m\\
\small Highways & \small 250 & \small \$250 m & \small 200 & \small \$250 m\\
\small Medicare & \small 50,000 & \small \$700.00 & \small 45,000 & \small \$700.00\\
\small Social Security & \small 55,000 & \small\$1,200.00 & \small 100,000 & \small \$1,100.00
\end{tabular}
\newline \newline
\small Calculate the Nominal GDP for 2017.\\
\(\text{Norminal GDP}_{gs2017} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2017}} = 1,000 \times \$300 m+250 \times \$250 m+50,000 \times\$700.00+55,000 \times\$1,200.00 = \textbf{362,601,000,000}\)
\newline
\small Calculate the Real GDP with a base year of 2016.\\
\(\text{Real GDP}_{gs2016} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2016}} = 1,000 \times \$280 m+250 \times \$250 m+50,000 \times\$700.00+55,000 \times\$1,100.00 = \textbf{342,595,500,000}\)
\subsection*{\small \bfseries Investment Spending}
\begin{tabular}{l c c c c c}
\small \bfseries Goods/Services & \small \bfseries 2017 Quantity & \small \bfseries 2017 Price & \small \bfseries 2016 Quantity & \small \bfseries 2016 Price\\
\small Commercial Towers & \small 250 & \small \$500 m & \small 170 & \small \$480 m\\
\small Used Machinery & \small 850 & \small \$525 m & \small 700 & \small \$500 m\\
\small Condominiums & \small 350 & \small \$750 m & \small 245 & \small \$740 m\\
\small Business Parks & \small 225 & \small\$450 m & \small 100 & \small \$380 m
\end{tabular}
\newline \newline
\small Calculate the Nominal GDP for 2017.\\
\(\text{Norminal GDP}_{is2017} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2017}} = 250 \times \$500 m+850 \times \$525 m+350 \times\$750 m+225 \times\$450 m = 935000 m = \textbf{935,000,000,000}\)
\clearpage
\small Calculate the Real GDP with a base year of 2016.\\
\(\text{Real GDP}_{is2016} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2016}} = 250 \times \$480 m+850 \times \$500 m+350 \times\$740 m+225 \times\$380 m = 889500 m = \textbf{889,500,000,000}\)
\subsection*{\small \bfseries Net Exports}
\begin{tabular}{l c c c c c}
\small \bfseries Goods/Services & \small \bfseries 2017 Quantity & \small \bfseries 2017 Price & \small \bfseries 2016 Quantity & \small \bfseries 2016 Price\\
\small Technology & \small 1,000 & \small \$300,000 & \small 1,000 & \small \$280,000\\
\small Military Arms & \small 5,000 & \small \$25,000 & \small 7,000 & \small \$20,000\\
\small Textiles & \small 750,000 & \small \$49.99 & \small 845,000 & \small \$39.99\\
\small Toys & \small 925,000 & \small\$19.99 & \small 900,000 & \small \$18.99
\end{tabular}
\newline \newline
\begin{small}
Calculate the Nominal GDP for 2017.\\
\(\text{Norminal GDP}_{ne2017} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2017}} = 1,000 \times \$300,000+5,000 \times \$25,000+750,000 \times\$49.99 m+925,000 \times\$19.99 = \textbf{480,983,250}\)
\newline
Calculate the Real GDP with a base year of 2016.\\
\(\text{Real GDP}_{ne2016} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2016}} = 1,000 \times \$280,000+5,000 \times \$20,000+750,000 \times\$39.99 m+925,000 \times\$18.99 = \textbf{427,558,250}\)
\newline
Add all of the Nominal GDP for 2017.\\
\(\text{Nominal GDP}_{2017} = \text{Norminal GDP}_{cs2017} + \text{Norminal GDP}_{gs2017} + \text{Norminal GDP}_{is2017} + \text{Norminal GDP}_{ne2017} = 87,760,750 + 362,601,000,000 + 935,000,000,000 - 480,983,250 = \textbf{1,297,207,777,500}\)
\newline
Add all of the Real GDP with a base year of 2016.\\
\(\text{Real GDP}_{2017} = \text{Real GDP}_{cs2017} + \text{Real GDP}_{gs2017} + \text{Real GDP}_{is2017} + \text{Real GDP}_{ne2017} = 82,498,250 + 342,595,500,000 + 889,500,000,000 - 427,558,250 = \textbf{1,231,750,440,000}\)
\newline
Calculate the GDP Deflator.\\
\(\text{GDP Deflator} = \text{Nominal GDP} \div \text{Real GDP} \times 100 = 1,297,207,777,500 \div 1,231,750,440,000 \times 100 = \textbf{105.314172041}\)
\newline
Explain what is happening to the economy?\\
\end{small}
\end{flushleft}
\end{document}
答案1
仅对文档的第一行进行一些修复:
(我尽量用常见的方法)
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{mathptmx}
\usepackage{parskip}%See Comment 1
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\usepackage{array}%See Comment 2
\newcolumntype{G}{>{\small}c}
\usepackage{bm}%See Comment 5
\usepackage{titlesec}%See comment 1.5
\titleformat*{\section}{\bfseries\small}
\titleformat*{\subsection}{\bfseries\small}
\begin{document}
%Comment 1
%\begin{flushleft} No needed and not really correct
% Added parskip package and \setlength{\parindent}{0pt} for this
% Also used \setlength\parindent{0pt} to let you use empty line instead of \\
\section*{First Economic Assignment: GDP Deflator}%Used titlesec package to set a style for sections and subsections
\subsection*{Consumer Spending}
\begin{tabular}{>{\small}l *{5}{G}}%Comment 2
%Added \small in every comumn and
%automated c columntype insertion to *{5}{G}
%G is a newcolumntype defined above by array package usega
%See also sunitx package too for S column type that can align numbers to their dot
\bfseries Goods/Services & \bfseries 2017 Quantity & \bfseries 2017 Price &\bfseries 2016 Quantity & \bfseries2016 Price\\
%Removed all \small because of added command in columntype
Sushi & 625,000 & \$30.00 & 600,000 & \$28.00\\
Jamba Juice & 750,000 & \$5.35 & 700,000 & \$5.00\\
Samsung 4k Television & 50,000 & \$799.99 & 45,000 & \$749.99\\
Samsung Note 8 & 125,000 & \$199.99 & 100,000 & \$189.99
\end{tabular}
%Comment 3
%\newline \newline
%Replaced above with vspace
\vspace{2\baselineskip}
\small Calculate the Nominal GDP for 2017.
%Comment 4: Replaced with below and removed \newline
%\(\text{Norminal GDP}_{cs2017} = \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2017}} = 625,000 \times \$30.00+750,000 \times \$5.35+50,000 \times\$799.99+125,000 \times\$199.99 = \textbf{87,760,750}\)
%\newline
% Doesn't needed
%used align
\begin{align*}
\text{Normal GDP}_{cs2017} &= \sum{\text{Quantity}_{2017} \cdot \text{Price}_{2017}}\\& = 625,000 \times \$30.00+750,000 \times \$5.35+50,000 \times\$799.99+125,000 \times\$199.99 \\&= \bm{87,760,750}%Comment 5 Used \bm command for bold math instead of \textbf
\end{align*}
\end{document}
其余部分似乎还好(您可能希望按照@Zarco 的建议在表参数中添加@{})
输出: