4

**Second edit: I changed the title to make sure I didn't confuse anybody. After seeing everybody's comments, I have realized where I was confusing about.

  1. *What's the efficient way to make all the texts "\flushleft"? Problem solved. Thanks to @koleygr(see the first answer, comment 1)
  2. *What's the efficient way to "style" all the elements of a tabular instead of styling them individually? Problem solved. Ditto(comment 2).
  3. *What's the efficient way to create several new lines? Problem solved. Ditto(comment 3). More questions to be solved:
  4. How do I know how many inches or centimeter in \vspace? With experience?
  5. When I wrote \documentclass[12pt]{article}, does the font size differ from the font size in M$ Word? Because I was reinventing wheels from the document our professor gave to me, but the font size is not exactly the same.
  6. If inside a \(\) have some text which I don't want it to be italic, do I have to write \text{} every time?

How's everybody! I am going to university after this semester. I am a Math major and I want to learn LaTeX in advance. I have been learning LaTeX for a while and this is the first time writing Econ assignment using LaTeX.

How do you guys think about the code? Anything that needs improvement?

One thing I noticed while writing was the table I created is a little bit offset compared to other texts above. Is there any way to fix this?

Best wishes to all of you.

Here are my results: Page 1 Page 2

Here are my codes:

\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}
  • 4
    I have to tell you that this is not the way that this site and forums work. If somebody will help you, it will be just a personal help to you. Nobody else will be helped by such a post. If you have some specific problem you may ask about thet, so that next visitors or some google search will lead to your question and help others too. [A payed service -like freelancer sites- are appropriate for such jobs... but not a forum] – koleygr Feb 28 '18 at 23:29
  • for table "fix": \begin{tabular}{@{} l c c c c c} (but this "off-set is intentional) , all others is opinion based ... if you first like to master table settings, read some introductory text about tables as https://en.wikibooks.org/wiki/LaTeX/Tables and search through this site for tag tables. – Zarko Feb 28 '18 at 23:43
  • \section*{\small \bfseries First Economic Assignment: GDP Deflator} Section etc. headings are using \bfseries (or bold font) already, however, they are not using \small inside by default –  Feb 28 '18 at 23:53
  • @koleygr I don't entirely agree. We have other questions of this general kind and nobody raises any objections. The main difference, as far as I can tell, is that those questions generally involve more experienced users whose code is typically more sophisticated in some way. But I can't see why the level of an OP's expertise should determine whether or not such a request is considered a resonable one for this site. And, anyway, SE is adamant that its sites are NOT forums. – cfr Mar 01 '18 at 00:56
  • @cfr My comment was about asking more specific question. I haven't really found many questions in style "How to improve this code" that are accepted or that have no objection. (But possibly this just happened). "How to improve this table" is a usual question but it is about something more specific. "Suggested way for left align text" also. So, my objection was about the future value of the question, not of the expertise of the OP. Also I didn't flag it... just added a comment to help the OP to ask more valuable (for every user) questions. Even not a forum I thought SE uses this philosophy too. – koleygr Mar 01 '18 at 01:06
  • @koleygr For example, https://tex.stackexchange.com/questions/26479/can-my-latex-maths-code-be-improved, But I don't entirely disagree with you, either. It is just that given the first questions which nobody raises an eyebrow at, this one seemed pretty good to me. But you even plan to delete your answer. If that's because the question won't be generally useful, you have an awful lot of questions to get rid of on this site. ;) – cfr Mar 01 '18 at 01:44
  • At first glance: (1) Do not place a \small in every cell. Just enclose the whole tabular with {\small } (2) Instead of c columns, try with digital alignements (see packages siunitx or dcolumn) and (3) if the tabular do not take de full text width, IMO look better centered. {\centering ... } – Fran Mar 01 '18 at 02:16
  • @koleygr Sorry about that if I went against the community regulations or something. Tbh, I have fixed all my questions while writing it(all of them works), but I wonder if there's more efficient way to do so. – Yuchen Zhang Mar 01 '18 at 03:06
  • @koleygr Maybe it is not that clear at a glance. I will try to avoid writing vague descriptions next time. – Yuchen Zhang Mar 01 '18 at 03:08
  • @Fran Thank you! It was so annoying to make each text small. That was the reason why I ask if there's another way to do so. – Yuchen Zhang Mar 01 '18 at 03:10
  • @cfr, I found this exactly post before my comment (answer to you) above. But even this has a (math) that makes is somehow more useful because it happens to have very common beginner math mistakes. Here it would be better if the question could split to 3 with titles and contents like "tabular with many small elements" , "all text and tabulars left aligned" and "bold and small in section". Of course in such case he could possibly find duplicates and the worse: He could have known his mistakes before ask... (only an experienced user could know what part need improvements)... So, I can understand. – koleygr Mar 01 '18 at 03:33
  • @YuchenZhang You don't have to be sorry, and you didn't break any rules... My comment is upvoted as useful about being more more specific (opinion based answers are closed) but nobody of them flagged your question as a question that has to be deleted or closed etc (Instead of that it is upvoted by 3 people -shows real effort and most people first questions doesn't-). My answer has possibly things that can help you But I said that I am going to delete it because 1) it was an answer in hurry without the needed attention. 2) Found upvotes on my comment and if nobody would answer (-> my fault) – koleygr Mar 01 '18 at 03:46
  • @koleygr And how is a beginner to know if whatever mistakes they have made are common beginners' mistakes or not? I think this was really a pretty good first question - really good for somebody new to LaTeX. What do you want? Blood?! – cfr Mar 01 '18 at 04:05
  • @cfr It's OK guys! I should have been more responsible for my question. This was the way I learn C++ before(Annoying ppl and asking them what they did). Maybe I should have read more before asking. – Yuchen Zhang Mar 01 '18 at 04:14
  • @cfr ... Hahaha... Just testing my (political) charisma skills. I have 4 votes by leading people to adapt my mistake... Need to test it other hours too... Hahaha. Sure it is a good question. May be a title "Bigginer in LaTeX and tabular" would be better since it can't be broken to more questions (tabular was the most discussed mistakes). Yuchen... your question is fine... May be a change in the title would make it more useful... But it is ok if you don't want... – koleygr Mar 01 '18 at 04:17
  • One question per question please, not several unrelated questions hidden ine one. – Johannes_B Mar 01 '18 at 06:43

1 Answers1

2

Just some fixes of the first lines of your document:

(I used common ways as far as this can be said)

\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}

The rest seems ok (You may be want to add @{} in table arguments as @Zarco suggested)

Output:

enter image description here

koleygr
  • 20,105