0

Problem

I have a bunch of changelog.md files for our software that use backticks for inline code. I pull them as part of the documentation build process and compile a PDF with latex. Latex seems unable to properly line break these kind of inline code pieces, as seen in the screenshot. Does anyone know a workaround for this? Sometimes they go completely out of the page, depending on length. For longer snippets we use listings, but that's not an option for these inline code pieces.Also, our developers write their changelogs in github-markdown and would not include any kind of latex hints or anything, so I need to convert regular gh-markdown into a PDF by running it through a latex pipeline. So I can't go to specific places in latex code and wrap affected lines into a special environment/command.

String going out of bounds

The respective line in markdown is the following:

- the connection name to the PLC must be identical (see ```opvconfig\opvbase\devices\...\config.json```), because it is the first element of ```target_ref ```

For using markdown in latex we use the 'standard' markdown package: http://ctan.mirror.norbert-ruehl.de/macros/generic/markdown/markdown.html

To set up the config for the markdown package, we use this:

\markdownSetup{
      fencedCode=true,
      renderers = {
        interblockSeparator = {},
        headingOne = \chapter*{#1},
        headingTwo = \section*{#1},
        headingThree = \subsection*{#1},
        headingFour = \subsubsection*{#1},
        headingFive = \paragraph*{#1},
        headingSix = #1,
      }
    }

What I tried so far

  • replaced the 3 backticks by a single on, didn't work
  • tried several different options for markdownSetup
  • tried several lstset options (including breaklines=true)
  • Found this question wrapping inline long lines and adding background color and tried out a few of the links they posted under challenges

From what I have read so far, I get the impression that it is not possible to achieve as I want and that I should 'just switch to pandoc', but pandoc is unfortunately not an option. I even tried pandoc, but it introduced even more problems, like listings not working properly. (We use packages like https://github.com/xgirma/latex-javaScript)

Donvini
  • 85
  • 1
    What about escaping to TeX or using lstlistings directly with file content? – Oleg Lobachev Apr 07 '22 at 11:26
  • 1
    It has been a while, but I think I encountered the same problem when translating quoted (backticked?) code to \texttt{backticked code}, because that code would end up in a single hbox and that's your issue. You need to find a different way to translate the backticks. I don't recall my solution though. :-( Maybe you can put something along the lines of enabling different typeset through \texttt and then put a \normalfont at the end. – Bananguin Apr 07 '22 at 11:41
  • As far as I know, your only option to get a linebreak in the verbatim text is to use fvextra package which has multiple options to deal with that. But I would be curious about the reason for prioritizing an unmaintained javascript package over pandoc ... – Tomáš Kruliš Apr 07 '22 at 16:26
  • By default, the markdown package renders code spans using the \texttt LaTeX command. You can enable hyphenation within \texttt using the hyphenat package. See also https://tex.stackexchange.com/a/543/70941. – Witiko May 03 '22 at 08:55

0 Answers0