Skip to main content

latex-practice

Typesetting a Complete Paper

This chapter assembles all the knowledge from the previous ten chapters: using a multi-file project, typesetting a complete short paper with abstract, formulas, figures, tables, and references from scratch. It is recommended to follow along—watching is not the same as doing; walking through the whole process once makes LaTeX truly yours.

Project Structure

First plan the directory: skeleton separated from content, one file per chapter.

paper/
├── main.tex # Skeleton: preamble + assembling chapters in order
├── refs.bib # Reference database
├── figures/
│ └── fit.png # Figure
└── sections/
├── abstract.tex # Abstract
├── intro.tex # Introduction
├── method.tex # Method
├── result.tex # Experimental results
└── conclusion.tex# Conclusion

main.tex: Project Skeleton

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

Example: main.tex

\documentclass[12pt, a4paper]{ctexart}

% -------- Page layout and basic packages --------
\usepackage{geometry}
\geometry{margin=2.5cm}
\usepackage{amsmath, amssymb} % Math
\usepackage{graphicx} % Graphics
\usepackage{booktabs, multirow} % Three-line tables
\usepackage[colorlinks=true, linkcolor=blue,
citecolor=blue, urlcolor=blue]{hyperref}

% -------- Title information --------
\title{Research on Periodic Signal Fitting Based on Least Squares}
\author{UniResearch}
\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}

Research on Periodic Signal Fitting Based on Least Squares

UniResearch

August 20, 2026

Abstract This paper studies parametric modeling of periodic signals. Based on the least squares criterion, the estimation procedure for the sinusoidal model y=Asin(ωx+φ)+cy = A\sin(\omega x + \varphi) + c is derived, and the method's effectiveness is verified on synthetic data. Experiments show that under low-noise conditions, the relative fitting error is below 1%.

Keywords: least squares; periodic signal; parameter estimation

Content of Each Chapter

Each file is just ordinary body text; the abstract and introduction are shown as examples.

Example: sections/abstract.tex

\begin{abstract}
This paper studies parametric modeling of periodic signals. Based on the least squares criterion, the estimation procedure for the sinusoidal model
$y = A\sin(\omega x + \varphi) + c$ is derived,
and the method's effectiveness is verified on synthetic data.

Experiments show that under low-noise conditions, the relative fitting error is below 1\%.

\medskip
\noindent\textbf{Keywords:} least squares; periodic signal; parameter estimation
\end{abstract}

Abstract This paper studies parametric modeling of periodic signals. Based on the least squares criterion, the estimation procedure for the sinusoidal model y=Asin(ωx+φ)+cy = A\sin(\omega x + \varphi) + c is derived, and the method's effectiveness is verified on synthetic data. Experiments show that under low-noise conditions, the relative fitting error is below 1%.

Keywords: least squares; periodic signal; parameter estimation

Example: sections/intro.tex

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

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

1 Introduction

Periodic signals are widely found in communications, vibration analysis, and biomedical engineering; parametric modeling of such signals is the common foundation for filtering, prediction, and compression[2]. The classical least squares method provides a systematic solution framework for model parameter estimation[1].

The rest of this paper is organized as follows: Section 2 establishes the model and gives the solution steps, Section 3 reports the experimental results, and Section 4 concludes.

The method section holds formulas, and the experiment section holds figures and tables—you have already seen all the routines.

Example: sections/method.tex (formula 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 amplitude, $\omega$ is angular frequency, $\varphi$ is initial phase, and $c$ is the DC component.

The goal of parameter estimation is to minimize the residual sum of squares
\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 fixed $\omega$, Eq.~\eqref{eq:loss} is a linear least squares problem with respect to the other parameters,
and can be solved directly by the normal equations.

2 Method

Consider the following sinusoidal model:

y=Asin(ωx+φ)+c(1)y = A \sin(\omega x + \varphi) + c \tag{1}

where AA is amplitude, ω\omega is angular frequency, φ\varphi is initial phase, and cc is the DC component.

The goal of parameter estimation is to minimize the residual sum of squares

S(A,ω,φ,c)=i=1n(yiAsin(ωxi+φ)c)2(2)S(A, \omega, \varphi, c) = \sum_{i=1}^n \left( y_i - A \sin(\omega x_i + \varphi) - c \right)^2 \tag{2}

For fixed ω\omega, Eq. (2) is a linear least squares problem with respect to the other parameters and can be solved directly by the normal equations.

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

\section{Experimental Results}\label{sec:result}
Synthetic data were generated by sampling $n = 200$ points uniformly on $[0, 2\pi]$,
and Gaussian noise with standard deviation $0.05$ was added.
The comparison between the fitted curve and noisy sample points is shown in Figure~\ref{fig:fit},
and error metrics under different noise levels are shown in Table~\ref{tab:err}.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.65\textwidth]{figures/fit}
\caption{Fitted curve (solid line) and noisy sample 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}
\end{section}

3 Experimental Results

Synthetic data were generated by sampling n=200n = 200 points uniformly on [0,2π][0, 2\pi], and Gaussian noise with standard deviation 0.05 was added. The comparison between the fitted curve and noisy sample points is shown in Figure 1; error metrics under different noise levels are shown in Table 1.

Fitted curve

Figure 1: Fitted curve (solid line) and noisy sample points (scatter)

Table 1: Root Mean Square Error under Different Noise Levels

Noise Std. Dev.0.010.050.10RMSE0.0110.0530.104Relative Error1.1%5.3%10.4%\begin{array}{lccc} \hline \text{Noise Std. Dev.} & 0.01 & 0.05 & 0.10 \\ \hline \text{RMSE} & 0.011 & 0.053 & 0.104 \\ \text{Relative Error} & 1.1\% & 5.3\% & 10.4\% \\ \hline \end{array}

refs.bib contains two bibliographic entries, and the body cites \cite{oppenheim1997} and \cite{bjorck1996} (full syntax in Chapter 9).

Compilation and Output

For a multi-file project, only main.tex needs to be compiled; \input will expand automatically. The full workflow with bibliography:

$ cd paper
$ latexmk -xelatex main.tex # One-click completion (recommended)
# Or manually four steps: xelatex -> bibtex -> xelatex -> xelatex

First-page output (title area, abstract and keywords, introduction citation numbers):

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

\begin{abstract}
This paper studies parametric modeling of periodic signals. Based on the least squares criterion, the estimation procedure for the sinusoidal model
$y = A\sin(\omega x + \varphi) + c$ is derived,
and the method's effectiveness is verified on synthetic data.

Experiments show that under low-noise conditions, the relative fitting error is below 1\%.

\medskip
\noindent\textbf{Keywords:} least squares; periodic signal; parameter estimation
\end{abstract}

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

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

Research on Periodic Signal Fitting Based on Least Squares

UniResearch

August 20, 2026

Abstract

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

Keywords: least squares; periodic signal; parameter estimation

1 Introduction

Periodic signals are widely found in communications, vibration analysis, and biomedical engineering; parametric modeling of such signals is the common foundation for filtering, prediction, and compression[2]. The classical least squares method provides a systematic solution framework for model parameter estimation[1].

The rest of this paper is organized as follows: Section 2 establishes the model and gives the solution steps, Section 3 reports the experimental results, and Section 4 concludes.

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

\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 amplitude, $\omega$ is angular frequency, $\varphi$ is initial phase, and $c$ is the DC component.

The goal of parameter estimation is to minimize the residual sum of squares
\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 fixed $\omega$, Eq.~\eqref{eq:loss} is a linear least squares problem with respect to the other parameters,
and can be solved directly by the normal equations; $\omega$ is determined by grid search over the interval $[\omega_{\min}, \omega_{\max}]$,
and the parameter combination that minimizes $S$ is selected.

\section{Experimental Results}\label{sec:result}
Synthetic data were generated by sampling $n = 200$ points uniformly on $[0, 2\pi]$,
and Gaussian noise with standard deviation $0.05$ was added.
The comparison between the fitted curve and noisy sample points is shown in Figure~\ref{fig:fit},
and error metrics under different noise levels are shown in Table~\ref{tab:err}.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.65\textwidth]{figures/fit}
\caption{Fitted curve (solid line) and noisy sample 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}

\section{Conclusion}\label{sec:conclusion}
This paper decomposes sinusoidal fitting into two steps, "grid search + linear least squares,"
with a simple process and stable solution.
Future work will extend the method to multi-component harmonic signals,
and study automatic estimation of frequency initial values.

\begin{thebibliography}{9}
\bibitem{bjorck1996}
Åke Björck. \textit{Numerical Methods for Least Squares Problems}. SIAM, 1996.
\bibitem{oppenheim1997}
Alan V. Oppenheim and Alan S. Willsky. \textit{Signals and Systems}. Prentice Hall, 2 edition, 1997.
\end{thebibliography}

2 Method

Consider the following sinusoidal model:

y=Asin(ωx+φ)+c(1)y = A \sin(\omega x + \varphi) + c \tag{1}

where AA is amplitude, ω\omega is angular frequency, φ\varphi is initial phase, and cc is the DC component.

The goal of parameter estimation is to minimize the residual sum of squares

S(A,ω,φ,c)=i=1n(yiAsin(ωxi+φ)c)2(2)S(A, \omega, \varphi, c) = \sum_{i=1}^n \left( y_i - A \sin(\omega x_i + \varphi) - c \right)^2 \tag{2}

For fixed ω\omega, Eq. (2) is a linear least squares problem with respect to the other parameters and can be solved directly by the normal equations; ω\omega is determined by grid search over the interval [ω_min, ω_max], and the parameter combination that minimizes SS is selected.

3 Experimental Results

Synthetic data were generated by sampling n=200n = 200 points uniformly on [0,2π][0, 2\pi], and Gaussian noise with standard deviation 0.05 was added. The comparison between the fitted curve and noisy sample points is shown in Figure 1; error metrics under different noise levels are shown in Table 1.

Fitted curve

Figure 1: Fitted curve (solid line) and noisy sample points (scatter)

Table 1: Root Mean Square Error under Different Noise Levels

Noise Std. Dev.0.010.050.10RMSE0.0110.0530.104Relative Error1.1%5.3%10.4%\begin{array}{lccc} \hline \text{Noise Std. Dev.} & 0.01 & 0.05 & 0.10 \\ \hline \text{RMSE} & 0.011 & 0.053 & 0.104 \\ \text{Relative Error} & 1.1\% & 5.3\% & 10.4\% \\ \hline \end{array}

4 Conclusion

This paper decomposes sinusoidal fitting into two steps, "grid search + linear least squares," with a simple process and stable solution. Future work will extend the method to multi-component harmonic signals and study automatic estimation of frequency initial values.

References

[1] Åke Björck. Numerical Methods for Least Squares Problems. SIAM, 1996.

[2] Alan V. Oppenheim and Alan S. Willsky. Signals and Systems. Prentice Hall, 2 edition, 1997.

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

Modify any reference or number and rerun latexmk; all numbers update automatically—this is the document that ten chapters of content bought you: "never manually check numbers again."

Real World: Start from a Template

In real paper writing, you should not build the skeleton from scratch—journals and schools provide ready-made templates.

Template SourceWhere to FindCharacteristics
Overleaf template libraryOverleaf → TemplatesThousands of thesis, journal, and poster templates, open with one click
Journal official websiteJournal Author Guidelines pageSubmission-specified format; always follow this
School thesis templateSchool library / GitHub search "[school name] + thesis"Meets school format review
GitHubSearch awesome-latex and similar collectionsCommunity-maintained templates and resource summaries

The one-sentence golden rule: Only fill in the placeholders, never touch the template structure. Those preamble settings in the template that you do not understand were tuned by others; deleting or changing one place may break the whole document.

Summary

AspectPractice in This Chapter
Project organizationmain.tex skeleton + sections/ chapters + figures/ images
Preamblegeometry, amsmath, graphicx, booktabs, hyperref
Body elementsAbstract, sections, formulas, figures/tables, cross-references, bibliography
Compilationlatexmk -xelatex in one step
Efficiency tipUse official templates for real submissions; only fill content, do not change structure