Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

LaTeX in Practice: Typesetting a Complete Paper

LaTeX in Practice: Typesetting a Complete Paper

This part assembles all the knowledge from the previous ten parts: using a multi-file project, typeset a complete mini-paper with abstract, formulas, figures, tables, and references from scratch.

It is recommended to do it once along the way - understanding by reading is not the same as knowing by writing; after going through the whole process once, LaTeX truly becomes yours.


Project Structure

First plan the structure: separate skeleton from content, one file per chapter.



paper/

├── main.tex            # 骨架:导言区 + 按顺序组装各章节

├── refs.bib            # 参考文献数据库

├── figures/

│   └── fit.png         # 插图

└── sections/

    ├── abstract.tex    # 摘要

    ├── intro.tex       # 引言

    ├── method.tex      # 方法

    ├── result.tex      # 实验结果

    └── conclusion.tex  # 结论


main.tex: Project Skeleton

The skeleton file does only three things: load packages, declare the title, and assemble in order.

Example: main.tex

\

documentclass

[

12pt, a4paper

]{

ctexart

}

% ---------- page and basic packages ----------

\

usepackage

{

geometry}
\geometry{margin=2.5cm}
\usepackage{amsmath, amssymb

}

     

% math

\

usepackage

{

graphicx

}

             

% figures

\

usepackage

{

booktabs, multirow

}

   

% three-line table

\

usepackage

[

colorlinks=true, linkcolor=blue,
            citecolor=blue, urlcolor=blue

]{

hyperref

}

% ---------- title information ----------

\

title

{

Research on Periodic Signal Fitting Based on Least Squares}
\author{RUNOOB}
\date{\today}

  \begin{document}       

    

  \maketitle       

  \input{sections/abstract

}

         

% abstract

\

input

{

sections/intro

}

             

% introduction

\

input

{

sections/method

}

           

% method

\

input

{

sections/result

}

           

% experimental results

\

input

{

sections/conclusion

}

       

% conclusion

\bibliographystyle

{

plain}
\bibliography{refs

}

               

% references

\end

{

document

}


Content of Each Section

Each file is a piece of ordinary body text; take the abstract and introduction as examples.

Example: sections/abstract.tex

\begin

{

abstract}
This paper studies parametric modeling of periodic signals and derives the sinusoidal model based on the least-squares criterion
the estimation procedure for $y = A\sin(\omega x + \varphi) + c$,
and verifies the method's effectiveness on synthetic data.
Experiments show that the relative fitting error is below 1% under low-noise conditions.

  \medskip       

  \noindent\textbf{关键词:}最小二乘法;周期信号;参数估计       

  \end{abstract

}

Example: sections/intro.tex

\

section

{

Introduction}\label{sec:intro}
Periodic signals are widespread in communications, vibration analysis, and biomedical engineering,
and parametric modeling of such signals is the common basis for filtering, prediction, and compression~\cite{oppenheim1997}.
The classic least-squares method provides a systematic solution framework for model parameter estimation~\cite{bjorck1996}.

The organization of this paper is as follows: Section~\ref{sec:method} builds the model and gives the solution steps,
Section~\ref{sec:result} reports experimental results, and Section~\ref{sec:conclusion

}

concludes the paper.

The method section holds formulas and the experiment section holds figures and tables; you have seen all the patterns.

Example: sections/method.tex (formulas part)

\

section

{

Method}\label{sec:method}
Consider the following sinusoidal model:
\begin{equation}\label{eq:model}
  y = A \sin(\omega x + \varphi) + c,
\end{equation}
where $A$ is the amplitude, $\omega$ is the angular frequency, $\varphi$ is the initial phase, and $c$ is the DC component.

The goal of parameter estimation is to minimize the sum of squared residuals
\begin{equation}\label{eq:loss}
  S(A, \omega, \varphi, c)
    = \sum_{i=1}^{n} \left( y_i - A \sin(\omega x_i + \varphi) - c \right)^2 .
\end{equation}
For a fixed $\omega$, equation~\eqref{eq:loss

}

is a linear least-squares problem with respect to the remaining parameters,

and can be solved directly from the normal equations.

Example: sections/result.tex (figures and tables part)

\

section

{

Experimental Results}\label{sec:result}
On $[0, 2\pi]$, $n = 200$ points are sampled at equal intervals to generate synthetic data,
and Gaussian noise with a standard deviation of $0.05$ is added.
The comparison between the fitted curve and the noisy sampled points is shown in Figure~\ref{fig:fit},
and the error metrics under different noise levels are listed in Table~\ref{tab:err}.

  \begin{figure}[htbp]       

  \centering
  \includegraphics[width=0.65\textwidth]{figures/fit}
  \caption{Fitted curve (solid line) and noisy sampled points (scatter)}
  \label{fig:fit}
\end{figure}

  \begin{table}[htbp]       

  \centering
  \caption{Root-mean-square error under different noise levels}
  \label{tab:err}
  \begin{tabular}{lccc}
    \toprule
    Noise std dev & 0.01 & 0.05 & 0.10 \
    \midrule
    RMSE & 0.011 & 0.053 & 0.104 \
    Relative error & 1.1% & 5.3% & 10.4% \
    \bottomrule
  \end{tabular}
\end{table

}

refs.bib holds two bibliographic entries, referenced in the body with \cite{oppenheim1997} and \cite{bjorck1996} (full syntax in Part 9).


Compilation and Effect

A multi-file project only needs to compile main.tex; \input is expanded automatically. The complete flow with references:



$ cd paper

$ latexmk -xelatex main.tex      # 一键完成(推荐)

# Or manually four steps: xelatex → bibtex → xelatex → xelatex

First-page effect (title block, abstract and keywords, citation numbers in the introduction):

Effect of the first page of the practical paper

Second-page effect (formula numbering and references, floating figure, three-line table, conclusion and references):

Effect of the second page of the practical paper

Check several "automation traces": the [1][2] in the introduction correspond one-to-one with the references at the end; figures and tables have their own numbers, and the body's "Figure 1" "Table 1" references are all correct; formulas (1)(2) are referenced by \eqref as the parenthesized form.

Change any reference or number and rerun latexmk once; all numbers update automatically - this is the document earned from ten parts of content, "never manually checking numbers again".


The Real World: Start from a Template

When actually writing a paper, you should not build the skeleton from scratch - journals and schools provide ready-made templates.

Template Sources Where to Find Feature
Overleaf Template Gallery Overleaf → Templates Thousands of thesis, journal, and poster templates, open with one click
Journal Website Journal Author Guidelines page The submission specifies the format; be sure to follow it
School Thesis Template Search the library / GitHub for "school name + thesis" Meets the in-school format review
GitHub Search collections like awesome-latex Community-maintained template and resource collections

The one-sentence mindset for using templates: only fill content into placeholders, never touch the template structure. Those preamble settings you do not understand are formats someone else tuned; deleting or changing one may break everything globally.


Summary

Stage This Part's Practice
Project Organization main.tex skeleton + sections/ by chapter + figures/ images
Preamble geometry, amsmath, graphicx, booktabs, hyperref
Body Elements Abstract, sections, formulas, figures, tables, cross-references, references
Compilation latexmk -xelatex completes in one command
Efficiency Tips For real submissions use the official template; only fill content, do not change structure