[Paper Review] Why Should Anyone use Colours? or, Syntax Highlighting Beyond Code Snippets
This paper advocates for widespread adoption of syntax highlighting—using color and font differentiation—in academic research papers to enhance clarity, concision, and correctness. It presents a practical LaTeX-based methodology for applying syntax highlighting to formal notations, such as language constructs and mathematical expressions, and demonstrates how it reduces ambiguity and improves readability without compromising typesetting integrity.
Syntax highlighting in the form of colours and font diversification, is an excellent tool to provide clarity, concision and correctness to writings. Unfortunately, this practice is not widely adopted, which results in often hard-to-parse papers. The reasons for this lack of adoption is that researchers often struggle to embrace new technologies, piling up unconvincing motivations. This paper argues against such motivations and justifies the usage of syntax highlighting so that it can become a new standard for dissemination of clearer and more understandable research. Moreover, this paper reports on the criticism grounded on the shortcomings of using syntax highlighting in LATEX and suggests remedies to that. We believe this paper can be used as a guide to using syntax highlighting as well as a reference to counter unconvincing motivations against it.
Motivation & Objective
- To address the lack of syntax highlighting in academic research papers despite its benefits in code and web content.
- To counter common objections against using colors and fonts in scholarly writing by providing technical and pedagogical justifications.
- To present a robust LaTeX-based system for applying syntax highlighting to formal notations, such as language definitions and logical expressions.
- To ensure that syntax highlighting does not interfere with LaTeX's typesetting, especially in aligned environments and nested structures.
- To establish syntax highlighting as a standard practice for clearer and more understandable research communication.
Proposed method
- Using custom LaTeX commands like \src{}, \trg{}, and \blk{} to apply distinct colors and fonts to source and target language constructs.
- Defining macros such as \srcletin{} that wrap only keywords in color commands, preserving alignment in environments like align*.
- Employing \newcommand{\comp}[1]{\blk{\left\llbracket\src{#1}\right\rrbracket}} to safely embed colored expressions within larger colored text.
- Using \trgbold{+} to apply bold formatting to specific symbols within colored text, ensuring visual consistency.
- Avoiding wrapping of arguments in color commands to prevent issues with alignment markers in math environments.
- Applying color and font differentiation to meta-variables (e.g., P in source vs. target language) to distinguish syntactic domains without subscripts.
Experimental results
Research questions
- RQ1How can syntax highlighting improve the readability and clarity of formal mathematical and logical notations in research papers?
- RQ2What are the main technical challenges in applying syntax highlighting to LaTeX-rendered academic papers?
- RQ3How can syntax highlighting be implemented in LaTeX without breaking alignment or typesetting in complex environments?
- RQ4What are the most effective color and font schemes for distinguishing syntactic domains in formal language definitions?
- RQ5How can researchers overcome resistance to adopting syntax highlighting due to perceived technical or aesthetic drawbacks?
Key findings
- Syntax highlighting significantly improves the readability of formal notations by visually distinguishing source and target language constructs without relying on subscripts.
- The proposed LaTeX macros allow for consistent and safe application of color and font differentiation even within complex math environments like align*.
- Properly structured macros—where only keywords are wrapped in color commands—prevent alignment issues and maintain typesetting correctness.
- Using distinct colors and fonts for different syntactic domains reduces cognitive load and enhances reader comprehension of formal definitions.
- The method enables seamless integration of syntax highlighting into existing LaTeX workflows without requiring changes to document classes or rendering pipelines.
- The paper successfully counters common objections to syntax highlighting by demonstrating its feasibility and benefits through concrete implementation and examples.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.