I have already found some similar solutions, but I was not able to adapt them to my requirements:
- A text fragment (e.g., source code) surrounded by other text should be highlighted with a background color. The background should have slightly rounded corners. A border for the background is nice to have, but not required.
- We can assume, that the text fragment is never longer than a complete line. However, it might happen, that the text fragment does not fit in the remaining width of the current line. I hoped to find one of these solutions for the problem:
- As usual text the not fitting part of the text fragment is wrapped to the next line (desired output example: as in the 1st image below, but with rounded corners).
- LaTeX determines that the text fragment does not fit in the current line and automatically places the whole text fragment in the next line. Does not look so nice, because it is not perfectly justified anymore, but it is OK. (desired output example: as in the 2nd image below, but with rounded corners).
- Line breaking, but no rounded corners: https://tex.stackexchange.com/a/6029/61241
- Rounded corners, but no line breaking: https://tex.stackexchange.com/a/36404/61241
- Force complete text fragment to the next line if it does not fit in the current line: https://tex.stackexchange.com/a/62347/61241
Using the suggestions from the 1st link (via soul or via the complex solution) I can get this output. It is almost perfect, but has no rounded corners. This question tells me that it is probably not possible using soul. Any way to modify the other solution?
soul with the solution from the 3rd link works, but without rounded corners, either (
\lword is defined in the 3rd link):