unofficial-uoregon-dissertation-formats / unofficial-uoregon-grad-school-dissertation-latex-markdown-apa-format

A dissertation LaTeX stylesheet with Markdown support for the University of Oregon using APA format (This repository is not officially associated with the University of Oregon).
Other
26 stars 18 forks source link

latex manual compile steps #1

Closed shaomeng closed 7 years ago

shaomeng commented 7 years ago

Hello,

I'm trying to use the latex template from this repository from the command line interface on my Mac. It seems the 0_uothesisapa_preamble.tex file is a starting point, so I typed "pdflatex 0_uothesisapa_preamble.tex." The compilation paused without finishing nor reporting any errors. Would you confirm if it is correct to start from 0_uothesisapa_preamble.tex ?

Thanks, Samuel

jglev commented 7 years ago

Hello,

Thank you for your message! The process for writing in raw LaTeX and compiling manually is a bit different than you tried, so I've written out some instructions below; I didn't write in raw LaTeX in my own dissertation workflow, so I just realized that that process isn't currently documented in the repo. If these steps / notes work for you, I'd be happy to work together to edit and add them to the repo.'s Readme, so that it's clearer for others in the future.

The direct answer to your question is that pdflatex should be run on a .tex file that is a combined version of all of the .tex files in this repo. and your dissertation's .tex files, in this order:

  1. 0_uothesisapa_preamble.tex
  2. 1_uothesisapa_prefatory_pages.tex
  3. 2_uothesisapa_begin_main_body_of_document.tex
  4. Your dissertation .tex file, with each chapter having a heading that looks like this: \chapter{Chapter name goes here} (e.g., \chapter{Methods})
  5. 5_uothesisapa_bibliography.tex
  6. 6_uothesisapa_end_of_document.tex

I've written some script steps to show how this could be automated. The steps below generally follow the "Markdown_to_LaTeX_PDF_Build_Script.sh" script from this repo. starting at line 254. I've pulled out just the TeX-relevant portions of that script.

The script steps below assume that you're cded into a directory that contains your dissertation .tex file(s) and .bib file(s) as well as all of the .tex files from the latex_files directory in this repo (and that those files have been edited following the notes in the Readme -- for example, editing "5_uothesisapa_bibliography.tex" to point to your Bibliography .bib file).

I'm also assuming here, for simplicity, that each of your dissertation chapters (e.g., Introduction, Methods, Results, Discussion) are in a separate .tex file, and that each does not have a heading (the script steps below will add a heading to each). If they are in a combined file with \chapter{Name of Chapter} headings, that's fine; you can take out those script steps below.

I haven't run the script steps below (i.e., be on the lookout for errors caused by typos), but think that they should give you a starting point to see what I'm talking about. Does this help you to get started? Let me know (including if the script doesn't make sense to you), and we can figure it out together from there.


#########################################
# SETTINGS
#########################################

introduction_section_tex_file="introduction.tex"
methods_section_tex_file="methods.tex"
results_section_tex_file="results.tex"
discussion_section_tex_file="discussion.tex"
appendices_tex_file="appendix.tex"

# This should NOT include a file extension (no ".tex" at the end)
# This is the combined tex file that *this script is going to create*
combined_tex_file_lacking_file_extension="/combined_sections_ready_for_rendering"

#########################################
# END SETTINGS
#########################################

#########################################
# CONTATENATE ALL PAPER SECTIONS, AND ADD LATEX CHAPTER HEADINGS
#########################################

# Note: In the lines below, 'if [ -s filename ]' checks whether a file exists and is not blank.

cat "$input_tex_files_directory/0_uothesisapa_preamble.tex" >> "$combined_tex_file_lacking_file_extension"

echo -e "\n\n" >> "$combined_tex_file_lacking_file_extension" # Add some extra newlines, just in case they're needed (so that the new file's section starts on its own line).
cat "$input_tex_files_directory/1_uothesisapa_prefatory_pages.tex" >> "$combined_tex_file_lacking_file_extension"

echo -e "\n\n" >> "$combined_tex_file_lacking_file_extension" # Add some extra newlines, just in case they're needed (so that the new file's section starts on its own line).
cat "$input_tex_files_directory/2_uothesisapa_begin_main_body_of_document.tex" >> "$combined_tex_file_lacking_file_extension"

echo "
%--- Chapter 1 ----------------------------------------------------------------%
\chapter{Introduction}
" >> "$combined_tex_file_lacking_file_extension"

cat "$location_for_temporary_build_files/$introduction_section_tex_file" >> "$combined_tex_file_lacking_file_extension"

echo "
%--- Chapter 2 ----------------------------------------------------------------%
\chapter{Methodology}
" >> "$combined_tex_file_lacking_file_extension"

cat "$location_for_temporary_build_files/$methods_section_tex_file" >> "$combined_tex_file_lacking_file_extension"

echo "
%--- Chapter 3 ----------------------------------------------------------------%
\chapter{ Results}
" >> "$combined_tex_file_lacking_file_extension"

cat "$location_for_temporary_build_files/$results_section_tex_file" >> "$combined_tex_file_lacking_file_extension"

echo "
%--- Chapter 4 ----------------------------------------------------------------%
\chapter{ Discussion}
" >> "$combined_tex_file_lacking_file_extension"
    cat "$location_for_temporary_build_files/$discussion_section_tex_file" >> "$combined_tex_file_lacking_file_extension"

# Note that Appendices must come before the References list, per the UO Grad School style guide (https://gradschool.uoregon.edu/sites/gradschool2.uoregon.edu/files/ETD_Style_Manual_2013_Feb_20.pdf), p. 32.

if [ -z "$appendices_tex_file" ] # If the variable $appendices_tex_file is not blank ("")
then
    echo -e "\n\n" >> "$combined_tex_file_lacking_file_extension"
    echo "%--- Appendices ----------------------------------------------------------------%" >> "$combined_tex_file_lacking_file_extension"
    cat "$input_tex_files_directory/appendices.tex" >> "$combined_tex_file_lacking_file_extension"
fi

echo "%--- Bibliography ----------------------------------------------------------------%" >> "$combined_tex_file_lacking_file_extension"
echo -e "\n\n" >> "$combined_tex_file_lacking_file_extension" # Add some extra newlines, just in case they're needed (so that the new file's section starts on its own line).
cat "$input_tex_files_directory/5_uothesisapa_bibliography.tex" >> "$combined_tex_file_lacking_file_extension"

echo "%--- Marker for end of document ----------------------------------------------------------------%" >> "$combined_tex_file_lacking_file_extension"
echo -e "\n\n" >> "$combined_tex_file_lacking_file_extension" # Add some extra newlines, just in case they're needed (so that the new file's section starts on its own line).
cat "$input_tex_files_directory/6_uothesisapa_end_of_document.tex" >> "$combined_tex_file_lacking_file_extension"

#########################################
# END OF CONTATENATE ALL PAPER SECTIONS, AND ADD LATEX CHAPTER HEADINGS
#########################################

#########################################
# RUN PDFLATEX AND BIBTEX ON THE COMBINED FILE TO RENDER A PDF
#########################################

# As weird as it looks, the correct/normal way to render a pdf file is to use five steps, running these commands in this order:
# 1. pdflatex file.tex
# 2. bibtex
# 3. pdflatex file.tex
# 4. pdflatex file.tex
# 5. pdflatex file.tex (This is one run more than normal, but seems to be necessary to get page numbers to render correctly -- without it, page numbers were off by one for me).
# The last few runs of pdflatex finish rendering references (including to tables and figures)

cd "$(dirname '$combined_tex_file_lacking_file_extension')" # Go into the directory of the combined tex file, for simplicity

echo "Running first round of pdflatex..."
sleep 2
pdflatex "$combined_tex_file_lacking_file_extension" # --output-directory "$location_for_temporary_build_files"

echo "Running bibtex..."
sleep 2
bibtex "$combined_tex_file_lacking_file_extension.aux"

echo "Running second round of pdflatex..."
sleep 2
pdflatex "$combined_tex_file_lacking_file_extension" # --output-directory "$location_for_temporary_build_files"

echo "Running third round of pdflatex..."
sleep 2
pdflatex "$combined_tex_file_lacking_file_extension" # --output-directory "$location_for_temporary_build_files"

echo "Running fourth round of pdflatex (this round was added because without it, Table of Contents page numbers were often off by 1)..."
sleep 2
pdflatex "$combined_tex_file_lacking_file_extension" # --output-directory "$location_for_temporary_build_files"

#########################################
# RUN PDFLATEX AND BIBTEX ON THE COMBINED FILE TO RENDER A PDF
#########################################

#########################################
# FINAL STEPS
#########################################

echo -e "Script finished. The rendered PDF can be found at \n\n$combined_tex_file_lacking_file_extension.pdf\n\n"

#########################################
# END FINAL STEPS
#########################################

My very best, Jacob

jglev commented 7 years ago

Just following-up -- did these updated instructions work for you?

shaomeng commented 7 years ago

Hello Jacob,

Sorry for the late response, but yes, it works, thanks for your notes.

Also, I've submitted a pull request to add a "Makefile" to automate the steps. It is the way I'm most comfortable with writing papers, and also many my colleagues in the Computer Science department. Feel free to merge (or reject) it.

Thanks, Samuel

jglev commented 7 years ago

Hi Samuel,

Thank you for letting me know! I've added my notes from above to the Readme, and added my example script as an additional file in the repository. If you have any comments on those, please feel free to reply here; in the meantime, I'm going to close this Issue.

I'll review your Pull Request in just a bit; thank you for it!

My very best, Jacob