Word wrapping text only when the hbox is overfull












0














I am using pandoc to process an markdown file that is causing me some issues with regard to in-line code blocks. In some cases I need to be able to have a long string without any punctuation or spaces remain together (not split across lines), and in other cases I have a long string without any spaces, but it does have punctuation, such as a comma (,), where it can be word wrapped. The problem is that I need to be able to detect when a overfull condition is going to occur and allow the string to be word wrapped at the comma (or other character). Here is an MWE (in LaTeX) that exhibits the



documentclass[12pt,]{article}
usepackage{lmodern}
usepackage{mathptmx} % makes Time New Roman the default font
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
% use upquote if available, for straight quotes in vebatim environments
IfFileExists{upquote.sty}{usepackage{upquote}}{}
% use microtype if available
IfFileExists{microtype.sty}{%
usepackage{microtype}
UseMicrotypeSet[protrusion,expansion]{basicmath} % disable protrusion for tt fonts
}{}
usepackage[margin=1in]{geometry}
usepackage{listings}
setlength{emergencystretch}{3em} % prevent overfull lines

usepackage{parskip}
usepackage{xcolor}
usepackage{soul}

definecolor{codegray}{HTML}{F0F0F0}
definecolor{framegray}{HTML}{C0C0C0}
sethlcolor{graycode}

% unbreak escaped space character in inline codeblocks
usepackage{xparse}
usepackage{ragged2e}

lethlORIGhl

ExplSyntaxOn
tl_new:N l_jdhao_hlx_tl
RenewDocumentCommandhl{m}{%
tl_set:Nnl_jdhao_hlx_tl{#1}%
tl_replace_all:Nnnl_jdhao_hlx_tl{ }{~}%
tl_replace_all:Nnnl_jdhao_hlx_tl{-/-}{mbox{-/-}}% added
exp_args:NVhlORIGl_jdhao_hlx_tl}%
ExplSyntaxOff

% override the inline coding style to show gray highlight box
% I needed to have the penalties, stretch and minimum because
% had the string FILENAME in an in-line code block that kept
% getting broken up as FILE at the end of one line and NAME at
% the start of the next, that needed to be kept together.
letoldTexttttexttt
renewcommand{texttt}[1]{%
begingroup
hyphenpenalty=10000
exhyphenpenalty=10000
lefthyphenmin=16
setlengthemergencystretch{hsize}hbadness=10000
sethlcolor{codegray}{ttfamilyhl{#1}}%
endgroup
}
RaggedRight
begin{document}
section{Example}label{example}

begin{itemize}
item
string does not contain any spaces and normally we don't wany to break
under normal conditions, but when the texttt{textbackslash{}hbox}
gets overfull by a bunch, texttt{"ab,alpha{[}127.0.0.1:8888{]},beta"}.
end{itemize}
end{document}


I'd like to be able to test if an overfull condition is about to occur and allow the string to be split at any of the commas.










share|improve this question



























    0














    I am using pandoc to process an markdown file that is causing me some issues with regard to in-line code blocks. In some cases I need to be able to have a long string without any punctuation or spaces remain together (not split across lines), and in other cases I have a long string without any spaces, but it does have punctuation, such as a comma (,), where it can be word wrapped. The problem is that I need to be able to detect when a overfull condition is going to occur and allow the string to be word wrapped at the comma (or other character). Here is an MWE (in LaTeX) that exhibits the



    documentclass[12pt,]{article}
    usepackage{lmodern}
    usepackage{mathptmx} % makes Time New Roman the default font
    usepackage[T1]{fontenc}
    usepackage[utf8]{inputenc}
    % use upquote if available, for straight quotes in vebatim environments
    IfFileExists{upquote.sty}{usepackage{upquote}}{}
    % use microtype if available
    IfFileExists{microtype.sty}{%
    usepackage{microtype}
    UseMicrotypeSet[protrusion,expansion]{basicmath} % disable protrusion for tt fonts
    }{}
    usepackage[margin=1in]{geometry}
    usepackage{listings}
    setlength{emergencystretch}{3em} % prevent overfull lines

    usepackage{parskip}
    usepackage{xcolor}
    usepackage{soul}

    definecolor{codegray}{HTML}{F0F0F0}
    definecolor{framegray}{HTML}{C0C0C0}
    sethlcolor{graycode}

    % unbreak escaped space character in inline codeblocks
    usepackage{xparse}
    usepackage{ragged2e}

    lethlORIGhl

    ExplSyntaxOn
    tl_new:N l_jdhao_hlx_tl
    RenewDocumentCommandhl{m}{%
    tl_set:Nnl_jdhao_hlx_tl{#1}%
    tl_replace_all:Nnnl_jdhao_hlx_tl{ }{~}%
    tl_replace_all:Nnnl_jdhao_hlx_tl{-/-}{mbox{-/-}}% added
    exp_args:NVhlORIGl_jdhao_hlx_tl}%
    ExplSyntaxOff

    % override the inline coding style to show gray highlight box
    % I needed to have the penalties, stretch and minimum because
    % had the string FILENAME in an in-line code block that kept
    % getting broken up as FILE at the end of one line and NAME at
    % the start of the next, that needed to be kept together.
    letoldTexttttexttt
    renewcommand{texttt}[1]{%
    begingroup
    hyphenpenalty=10000
    exhyphenpenalty=10000
    lefthyphenmin=16
    setlengthemergencystretch{hsize}hbadness=10000
    sethlcolor{codegray}{ttfamilyhl{#1}}%
    endgroup
    }
    RaggedRight
    begin{document}
    section{Example}label{example}

    begin{itemize}
    item
    string does not contain any spaces and normally we don't wany to break
    under normal conditions, but when the texttt{textbackslash{}hbox}
    gets overfull by a bunch, texttt{"ab,alpha{[}127.0.0.1:8888{]},beta"}.
    end{itemize}
    end{document}


    I'd like to be able to test if an overfull condition is about to occur and allow the string to be split at any of the commas.










    share|improve this question

























      0












      0








      0







      I am using pandoc to process an markdown file that is causing me some issues with regard to in-line code blocks. In some cases I need to be able to have a long string without any punctuation or spaces remain together (not split across lines), and in other cases I have a long string without any spaces, but it does have punctuation, such as a comma (,), where it can be word wrapped. The problem is that I need to be able to detect when a overfull condition is going to occur and allow the string to be word wrapped at the comma (or other character). Here is an MWE (in LaTeX) that exhibits the



      documentclass[12pt,]{article}
      usepackage{lmodern}
      usepackage{mathptmx} % makes Time New Roman the default font
      usepackage[T1]{fontenc}
      usepackage[utf8]{inputenc}
      % use upquote if available, for straight quotes in vebatim environments
      IfFileExists{upquote.sty}{usepackage{upquote}}{}
      % use microtype if available
      IfFileExists{microtype.sty}{%
      usepackage{microtype}
      UseMicrotypeSet[protrusion,expansion]{basicmath} % disable protrusion for tt fonts
      }{}
      usepackage[margin=1in]{geometry}
      usepackage{listings}
      setlength{emergencystretch}{3em} % prevent overfull lines

      usepackage{parskip}
      usepackage{xcolor}
      usepackage{soul}

      definecolor{codegray}{HTML}{F0F0F0}
      definecolor{framegray}{HTML}{C0C0C0}
      sethlcolor{graycode}

      % unbreak escaped space character in inline codeblocks
      usepackage{xparse}
      usepackage{ragged2e}

      lethlORIGhl

      ExplSyntaxOn
      tl_new:N l_jdhao_hlx_tl
      RenewDocumentCommandhl{m}{%
      tl_set:Nnl_jdhao_hlx_tl{#1}%
      tl_replace_all:Nnnl_jdhao_hlx_tl{ }{~}%
      tl_replace_all:Nnnl_jdhao_hlx_tl{-/-}{mbox{-/-}}% added
      exp_args:NVhlORIGl_jdhao_hlx_tl}%
      ExplSyntaxOff

      % override the inline coding style to show gray highlight box
      % I needed to have the penalties, stretch and minimum because
      % had the string FILENAME in an in-line code block that kept
      % getting broken up as FILE at the end of one line and NAME at
      % the start of the next, that needed to be kept together.
      letoldTexttttexttt
      renewcommand{texttt}[1]{%
      begingroup
      hyphenpenalty=10000
      exhyphenpenalty=10000
      lefthyphenmin=16
      setlengthemergencystretch{hsize}hbadness=10000
      sethlcolor{codegray}{ttfamilyhl{#1}}%
      endgroup
      }
      RaggedRight
      begin{document}
      section{Example}label{example}

      begin{itemize}
      item
      string does not contain any spaces and normally we don't wany to break
      under normal conditions, but when the texttt{textbackslash{}hbox}
      gets overfull by a bunch, texttt{"ab,alpha{[}127.0.0.1:8888{]},beta"}.
      end{itemize}
      end{document}


      I'd like to be able to test if an overfull condition is about to occur and allow the string to be split at any of the commas.










      share|improve this question













      I am using pandoc to process an markdown file that is causing me some issues with regard to in-line code blocks. In some cases I need to be able to have a long string without any punctuation or spaces remain together (not split across lines), and in other cases I have a long string without any spaces, but it does have punctuation, such as a comma (,), where it can be word wrapped. The problem is that I need to be able to detect when a overfull condition is going to occur and allow the string to be word wrapped at the comma (or other character). Here is an MWE (in LaTeX) that exhibits the



      documentclass[12pt,]{article}
      usepackage{lmodern}
      usepackage{mathptmx} % makes Time New Roman the default font
      usepackage[T1]{fontenc}
      usepackage[utf8]{inputenc}
      % use upquote if available, for straight quotes in vebatim environments
      IfFileExists{upquote.sty}{usepackage{upquote}}{}
      % use microtype if available
      IfFileExists{microtype.sty}{%
      usepackage{microtype}
      UseMicrotypeSet[protrusion,expansion]{basicmath} % disable protrusion for tt fonts
      }{}
      usepackage[margin=1in]{geometry}
      usepackage{listings}
      setlength{emergencystretch}{3em} % prevent overfull lines

      usepackage{parskip}
      usepackage{xcolor}
      usepackage{soul}

      definecolor{codegray}{HTML}{F0F0F0}
      definecolor{framegray}{HTML}{C0C0C0}
      sethlcolor{graycode}

      % unbreak escaped space character in inline codeblocks
      usepackage{xparse}
      usepackage{ragged2e}

      lethlORIGhl

      ExplSyntaxOn
      tl_new:N l_jdhao_hlx_tl
      RenewDocumentCommandhl{m}{%
      tl_set:Nnl_jdhao_hlx_tl{#1}%
      tl_replace_all:Nnnl_jdhao_hlx_tl{ }{~}%
      tl_replace_all:Nnnl_jdhao_hlx_tl{-/-}{mbox{-/-}}% added
      exp_args:NVhlORIGl_jdhao_hlx_tl}%
      ExplSyntaxOff

      % override the inline coding style to show gray highlight box
      % I needed to have the penalties, stretch and minimum because
      % had the string FILENAME in an in-line code block that kept
      % getting broken up as FILE at the end of one line and NAME at
      % the start of the next, that needed to be kept together.
      letoldTexttttexttt
      renewcommand{texttt}[1]{%
      begingroup
      hyphenpenalty=10000
      exhyphenpenalty=10000
      lefthyphenmin=16
      setlengthemergencystretch{hsize}hbadness=10000
      sethlcolor{codegray}{ttfamilyhl{#1}}%
      endgroup
      }
      RaggedRight
      begin{document}
      section{Example}label{example}

      begin{itemize}
      item
      string does not contain any spaces and normally we don't wany to break
      under normal conditions, but when the texttt{textbackslash{}hbox}
      gets overfull by a bunch, texttt{"ab,alpha{[}127.0.0.1:8888{]},beta"}.
      end{itemize}
      end{document}


      I'd like to be able to test if an overfull condition is about to occur and allow the string to be split at any of the commas.







      hyphenation pandoc typewriter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 16 mins ago









      JonBelanger

      299




      299



























          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467718%2fword-wrapping-text-only-when-the-hbox-is-overfull%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467718%2fword-wrapping-text-only-when-the-hbox-is-overfull%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Accessing regular linux commands in Huawei's Dopra Linux

          Can't connect RFCOMM socket: Host is down

          Kernel panic - not syncing: Fatal Exception in Interrupt