Markup-Based Professional Typesetting from Scratch: Structure, Formulas, and Engineering Practices
This article explains how developers can get started with markup-based professional typesetting without memorizing large amounts of syntax first. It covers the core paradigm of separating content from styling and source files from layout output, then walks through a minimal working loop, document skeleton (preamble and body), text and section structure, inline and display formulas with cross-references, figures and tables, bibliography management, and engineering practices such as templating, modularization, version control, and log-based troubleshooting. A four-week learning path with practice suggestions is included. Readers will gain a "structure–build–reference–reuse" engineering mindset that applies to papers, technical reports, project documentation, and books.
Professional typesetting is not mysterious. For developers, the most effective way to start is not to memorize a large amount of syntax, but to understand the core paradigm first: content is separated from styling, source files are separated from layout output, structure is described by markup, and the final document is generated by a build process. With markup-based typesetting, authors only care about “whether this piece of content is a heading, a paragraph, a formula, or a figure,” while styling, numbering, tables of contents, and cross-references are handled uniformly by templates and the build system. This model is especially well suited to technical documentation, papers, reports, and knowledge bases that need long-term maintenance.
Below is a learning path that goes from zero to usable: first get a minimal loop running, then fill in high-frequency capabilities such as formulas, figures, and citations, and finally manage templates and collaboration with engineering methods.
1. Set Up a Minimal Workflow First
At the beginner stage, the most important thing is not to master every feature, but to establish a stable loop:
- Write the source file: describe the document structure and content in plain text.
- Run the build: the typesetting system parses the markup and generates the layout file.
- Check the log: locate undefined references, missing files, unclosed environments, and similar issues.
- Iterate on the output: modify the source file and build again until both layout and content match expectations.
It is best to maintain only one main file at the beginning, and split it into chapters once the structure is stable. The main file handles global configuration and chapter inclusion, chapter files contain only body content, and images, tables, and references are archived separately. This reduces complexity for beginners and lays the groundwork for later templating.
2. Understand the Document Skeleton: Preamble and Body
A maintainable document is usually divided into two parts: the preamble handles global settings, and the body handles content organization. The preamble should stay “small and stable,” containing only the document class, page parameters, loading of required capabilities, theorem environment definitions, and metadata. The body is organized in the order “title page — abstract — table of contents — chapters — conclusion — references — appendix.”
Illustrative pseudo-code:
[Main file]Document class: article class, 11pt font, A4 paperPreamble:Load: math, graphics, page layout, hyperlinks, CJK supportSet: margins 2.5cm on all four sidesDefine: theorem, lemma, corollary, definition, example share one counterMetadata: title, author, dateBody:Generate title pageAbstract environment: problem overview, method, conclusionTable of contentsInclude chapter files: introduction, method, experiments, conclusionBibliography databaseAppendix (optional)End document
The point of this pseudo-code is not the exact syntax but structural awareness: global configuration is managed centrally, body content is split by chapter, and numbering and the table of contents are generated automatically. A common beginner mistake is scattering a large number of formatting commands throughout the body, so that changing the style later affects everything.
3. Text, Sections, and Lists: Get the Structure Right First
The first goal of technical writing is a clear structure. Keep section levels to three or four; deeper nesting loses readers. Each section title should describe its content accurately, avoiding vague names such as “Other” or “Miscellaneous.” Separate paragraphs with blank lines, and do not simulate layout with consecutive spaces or manual line breaks. Semantic elements such as emphasis, bold, and code should use the corresponding markup rather than manual font changes.
Lists are good for expressing steps, conditions, and comparisons. Unordered lists suit parallel points, and ordered lists suit procedural steps. For long lists, start each item with a verb or a noun phrase and keep the phrasing consistent. Chinese documents also need attention to fonts, line breaking, and punctuation compression; these should be configured uniformly in the template, and the body should not contain large amounts of manual typesetting fine-tuning.
4. Formulas: From Inline to Multi-Line Alignment
Formulas are a high-frequency capability in professional typesetting. Beginners only need three types:
- Inline formulas: embedded in a sentence, for example a²+b²=c², suitable for short variable relationships.
- Display formulas: on their own line and numbered, for example ∫e^{-x²}dx=√π, suitable for key results.
- Multi-line aligned formulas: used for derivations, aligned on equals signs or relation symbols, with selective numbering.
The key to writing formulas is “semantically complete and referenceable by number.” Every formula that needs to be referenced should have a stable label, such as eq:energy, and the body should cross-reference it as “see formula (eq:energy)” instead of hand-writing “formula (3).” Theorems, lemmas, corollaries, definitions, and examples should share one numbering scheme, and proof environments can end with a uniform symbol. Common mistakes include mismatched brackets, incorrect environment nesting, misplaced alignment symbols, and duplicate labels. When troubleshooting, first look at the line number in the build log, then narrow the problem down to a minimal formula that reproduces it.
5. Figures, Cross-References, and the Bibliography
Figures should be managed with floating bodies so the typesetting system decides their placement automatically. Every figure and table must have a caption and a label, and the body refers to them by label. Image files should be kept in a dedicated directory, with lowercase English filenames using hyphens, avoiding spaces and special characters. Tables should express structure first; do not align columns with large amounts of manual spacing, since column widths and alignment are controlled by the table environment.
References should be managed centrally: the body uses citation keys, and the build process generates the numbering and entries. Do not write sequence numbers manually, or the numbering of the whole document will break as soon as a new reference is inserted. The appendix holds derivations, supplementary data, glossaries, and other material that does not affect the main reading flow; it should use its own section structure and keep numbering continuous.
6. Engineering: Templates, Version Control, and Debugging
Once a document exceeds ten pages, it is time to adopt engineering habits:
- Templating: fix the document class, page parameters, common environments, and font settings in a template, so a new document only changes metadata and body content.
- Modularization: the main file keeps only global configuration and chapter inclusion, with one file per chapter, which makes parallel writing and review easier.
- Version control: source files are plain text and therefore naturally suited to version management; commit messages should state the intent, such as “add formula” or “adjust figure.”
- Keep build logs: archive build logs and output files by version, so the difference between “it built last time and fails now” is easy to locate.
- Minimize dependencies: every package or capability you load should have a clear reason, which reduces conflicts and migration costs.
For team collaboration, templates, sample documents, and build logs can be archived in general-purpose object storage, and build warnings can be routed to a log service. This kind of infrastructure can be provided by service categories such as the general-purpose object storage and log service offered by Baidu AI Cloud, but the typesetting solution itself should remain independent of any specific cloud vendor.
A common debugging checklist: undefined references usually come from inconsistent label spelling or too few build runs; missing files are mostly related to paths and filename casing; encoding problems should be resolved by standardizing on one encoding and avoiding mixed sources; unclosed environments require checking paired markup; package conflicts can be isolated step by step with a minimal reproduction. When a problem appears, read the first error in the log, not the last one.
7. Learning Path and Practice Suggestions
Week 1 goal: produce a short document with a title, abstract, table of contents, two chapters of body text, and references. Week 2 adds inline formulas, display formulas, multi-line alignment, theorems, and proofs. Week 3 adds images, tables, cross-references, and an appendix, and extracts the configuration into a template. Week 4 covers modular splitting and a collaboration exercise that simulates several people editing the same template.
When learning, modify a mature template first rather than inventing all the configuration from scratch; when a new requirement appears, check the official documentation and minimal examples first; and after mastering each capability, validate it with a small document. In the end you will find that the core of getting started with markup-based typesetting is not memorizing commands, but building an engineering mindset of “structure — build — reference — reuse.” Once you have this mindset, the same method can be extended step by step to papers, technical reports, project documentation, and book typesetting.
