0

I'm writing a text which has a lot of long Redis keys and camel cased text (like class names). This could be extended to long keywords and namespaces too. I want to accentuate these in way, so I'm using \texttt for this. The problem is that these are regularly overflowing out of the margin.

For example, the following snippet:

I'm having the issue that my Redis keys are overflowing, e.g. \texttt{Key:SubKey:SubSubKey:SubSubKey}.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Results in:

Example with overflowing Redis key

I have solved this with my custom \rediskey command:

\usepackage{xstring}
\newcommand{\rediskey}[1]{\texttt{\StrSubstitute{#1}{:}{:\allowbreak{}}}}

Which results in:

I'm having the issue that my Redis keys are overflowing, e.g. \rediskey{Key:SubKey:SubSubKey:SubSubKey}.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Example with non-overflowing Redis key

However, is their a better alternative to \texttt that might not have this problem?

Is there a better way to implement \rediskey?

Could someone help with the implementation of a \camelcase command that would allow breaks before a capital for example? (One caveat is that some of these are prefixed with 'I' to designate that it's an interface, and it would be weird to allow a break after one character.)

Aaron
  • 649
  • 1
    2012, doesn't time fly... https://tex.stackexchange.com/a/66603/1090 – David Carlisle Mar 31 '22 at 14:29
  • @DavidCarlisle, thanks for the suggestion. Had already seen that answer. I have however decided to restructure my document instead of using complicated custom commands. I'm now using e.g. footnotes, separate enumerations and appendices for long keywords. This prevents long lines and text getting out of margin. – Aaron Apr 05 '22 at 11:56
  • OK then So I marked this as a duplicate, hope that's OK, – David Carlisle Apr 05 '22 at 11:58

0 Answers0