6
$\begingroup$

I have written papers where code snippets are used much as one often uses equations: that is, a few lines of code are treated as a "display" block that should be part of the flow of the document, but separate from the paragraphs surrounding them. They are then followed by an explanation of the terms in that snippet. This is particularly useful when writing papers about software libraries, either to explain functionality or to illustrate how mathematical ideas map to the usage of library functions.

I'm trying to do this in LaTeX, and would like the code snippets to have syntax highlighting. My question is: What tools to accomplish this are supported by various journals relevant to computational chemistry/chemical physics/matter modeling?

To illustrate the problems I hope to avoid, this question comes from an experience I had in publishing a pair of papers that were very code-focused. We had used minted for nice, syntax-highlighted code. When we got to proofs, our code snippets had been treated as floating images that were then grouped together. Imagine grouping all the display equations in a paper -- the text where the display block was supposed to be becomes unintelligible. Additionally, because they were images, code snippets were also of all different sizes, and any change in proofs was like changing an image (i.e., we couldn't just say, "add a comma there," because they couldn't edit the text). It took months of iterating on the proofs before the PDF/print versions looked okay. Even after that, the HTML rendering of the article is pretty bad. So I would say that minted is not well-supported by JCTC (at least, as of 2018/2019 when that paper was published).

$\endgroup$
2
  • 1
    $\begingroup$ (Likely unfit as an answer): At the level of .tex, it is journal to decide if minted/pygmented code is permitted to enter as text, or (lacking text layer) image (only). (The SI are up to you.) By concept, your description of code block within an explanation is similar to literate programming. Emacs org mode is one application to support this (incl. describing blocks of code eventually exported [tangled] into their working e.g., Fortran code) and export to (tex/html/pdf/odt). See e.g., around 12:40 and 14:40 of John Kitchen's presentation here. $\endgroup$
    – Buttonwood
    Sep 14 '21 at 8:24
  • 1
    $\begingroup$ Related: tex.stackexchange.com/questions/102596/…. Unfortunately, it looks like minted is the most developed of these sorts of programs, so the other packages mentioned may not be any additional help. It does look the answerer there is the current maintainer of minted so perhaps they would be interested in feedback on the program being difficult to incorporate into publications. $\endgroup$
    – Tyberius
    Oct 29 '21 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.