Skip to main content
Minor text change
Source Link
MS-SPO
  • 24.8k
  • 3
  • 23
  • 65

Remember? StartDon't worry, start somewhere. Here: rebuilding what you posted for compiles. So it's a useful illustration of the process.

Remember? Start somewhere. Here: rebuilding what you posted for compiles. So it's a useful illustration of the process.

Remember? Don't worry, start somewhere. Here: rebuilding what you posted for compiles. So it's a useful illustration of the process.

Added refactord folder example
Source Link
MS-SPO
  • 24.8k
  • 3
  • 23
  • 65

Refactoring in itself has no limits. Above I showed impact on the segmentation into files and folders you presented. You can also do the same with content, i.e. your messages and findings. And as indicated you can refactor the folders. E.g. after some cycles you may have ended up like this:

+- main.tex
+  tikz/
|   +- ch1/
|       +- figure1.tex
|       +- figure2.tex
|   +- ch5/               % look ahead
|       +- figure1.tex
+- titlepage/
|   +- titlepage.tex
|- 1.a/
|   +- a.tex
|   +- a1.tex
|   +- a2.tex
|- 2.b/
|   +- b.tex
|   +- b1.tex
|   +- b2.tex

Refactoring in itself has no limits. Above I showed impact on the segmentation into files and folders you presented. You can also do the same with content, i.e. your messages and findings. And as indicated you can refactor the folders. E.g. after some cycles you may have ended up like this:

+- main.tex
+  tikz/
|   +- ch1/
|       +- figure1.tex
|       +- figure2.tex
|   +- ch5/               % look ahead
|       +- figure1.tex
+- titlepage/
|   +- titlepage.tex
|- 1.a/
|   +- a.tex
|   +- a1.tex
|   +- a2.tex
|- 2.b/
|   +- b.tex
|   +- b1.tex
|   +- b2.tex
Source Link
MS-SPO
  • 24.8k
  • 3
  • 23
  • 65

Let me illustrate my comment/proposal about continuous refactoring.

1. Step - rebuilding your example - V1

Remember? Start somewhere. Here: rebuilding what you posted for compiles. So it's a useful illustration of the process.

Preparations

I took the liberty to:

  • simplify your main.tex a little bit
  • put all your files and folders into folder V1 (see screenshot)
  • add more versions later, which match the numbers/versions in my Refactoring comment (in the main.tex versions)

Refactoring folders

You can use a similar versioning approach (copy folder Vn into V(n+1)), use Git etc. Versioning and backup are certainly on your todo- or done-lists.

So, this is what my main.tex looks like in V1, for a simplified start:

% ~~~ REFACTORING ~~~~~~~~~~~~~~~~~~~
%
%  1. getting copies to compile; introducing some formatting
%     activated 1.x and 2.x, dropped bibliography and appendices

\documentclass{report}
\usepackage{geometry}
\usepackage{lipsum}

%\usepackage[backend=biber,style=ieee]{biblatex}
%\addbibresource{bib.bib}

\usepackage[colorlinks]{hyperref}

% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
    \input{titlepage/titlepage}
    
    \tableofcontents
    
    \input{1.a/a}
    \input{2.b/b}
    %
    %\printbibliography[heading=bibintoc]
    %\listoffigures
    %\addcontentsline{toc}{chapter}{List of Figures}
    %\listoftables
    %\addcontentsline{toc}{chapter}{List of Tables}
    %
    %\appendix
    %
    %\input{appendix/appendixA}
    %\input{appendix/appendixB}

\end{document}

All needed .tex files are as you posted, within this folder structure:

+- main.tex
+- titlepage/
|   +- titlepage.tex
|- 1.a/
|   +- a.tex
|   +- a1.tex
|   +- a2.tex
|- 2.b/
|   +- b.tex
|   +- b1.tex
|   +- b2.tex

MY first refactoring-action

Preferences, tastes, perception etc. do vary from author to author. For me I'd already perceive your main-code as a bit crowded and hard to tell, what goes where. So I followed my addiction, to put some code-formatting, see above.

Now, after enough compiles, looking ahead, my first attention point was the titlepage-file ... it should be different in my view (still just for demo-purposes).

To emphasize, I line out the way of thinking, the self-improving process, and less the code itself.

2. Step - (first) adjustement of titlepage.tex - V2

Well, in main.tex nothing changed, besides my comment/protocol:

% ~~~ REFACTORING ~~~~~~~~~~~~~~~~~~~
%
%  1. getting copies to compile; introducing some formatting
%     activated 1.x and 2.x, dropped bibliography and appendices
%  2. refactoring titlepage

While in titlepage.tex I took the liberty to

  • introduce the titlepage-environement
  • add the folder structure (for fanciness) :
\begin{titlepage}
Fancy title:
\vspace{1cm}

    \lipsum[1-2]

\vspace{2cm}

Folders and files used:\bigskip
    \begin{verbatim}
+- main.tex
+- titlepage/
|   +- titlepage.tex
|- 1.a/
|   +- a.tex
|   +- a1.tex
|   +- a2.tex
|- 2.b/
|   +- b.tex
|   +- b1.tex
|   +- b2.tex
    \end{verbatim}
\end{titlepage}

There are millions other ways to design this one ...

titlepage

3. Step - enabling Chapter 1 to be compiled in two ways:

  1. within main.tex
  2. separately as a.tex

Required changes in main.tex

% ~~~ REFACTORING ~~~~~~~~~~~~~~~~~~~
% V#  changes
% --- -----------------------------------------------------------
%
%  1. getting copies to compile; introducing some formatting
%     activated 1.x and 2.x, dropped bibliography and appendices
%  2. refactoring titlepage
%  3. adding subfiles to chapter-1 file a.tex, so can be compiled alone

\documentclass{report}
\usepackage{subfiles}   % <<< NEW
\usepackage{geometry}
\usepackage{lipsum}

%\usepackage[backend=biber,style=ieee]{biblatex}
%\addbibresource{bib.bib}

\usepackage[colorlinks]{hyperref}

% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
    \input{titlepage/titlepage}
    
    \tableofcontents
    
%   \input{1.a/a}
    \subfile{1.a/a} % <<< CHANGED
    \input{2.b/b}
    %
    %\printbibliography[heading=bibintoc]
    %\listoffigures
    %\addcontentsline{toc}{chapter}{List of Figures}
    %\listoftables
    %\addcontentsline{toc}{chapter}{List of Tables}
    %
    %\appendix
    %
    %\input{appendix/appendixA}
    %\input{appendix/appendixB}

\end{document}

This lets you compile the whole thesis:

thesis

Chapter 1 as a pdf

a.tex:

\documentclass[../main]{subfiles}   % <<< new

\begin{document}        % <<< new
    \chapter{First}
    
    \input{1.a/a1}
    \input{1.a/a2}

\end{document}      % <<< new

Compiles into, which might be useful for separate inspection, review, crtics:

ch1

4. Process review and outlook

The 3 steps I showed here are already refactoring, like doing pottery on content:

  • start simple, with a goal in mind
  • gradually transform and check the outcome(s)

Wrt. your thesis I can think of a number of scenarios, like:

  • splitting some part of say a.1.tex into more subparts (growing, segmenting)
  • consolidating: perhaps later you feel, all b.tex* files should be in one b.tex (growning, merging)
  • you recognize, a separate tikz/ folder with standalone drawings is useful
  • later you do some finer segmentation on it, like tikz/ch1/, tikz/ch2/ etc.
  • and so on

It's all no big deal: you move intentionally and controlled, like a mountain climber, from save-to-save / safe-to-safe :)