Equation overflowing overfull hbox [duplicate]











up vote
1
down vote

favorite













This question already has an answer here:




  • lstlisting line wrapping

    1 answer




I have a question about showing C++ code in LateX



When I do the following, the C++ goes past the page. Is there a way to fix this?



documentclass{article} 

newcommand{dd}[1]{mathrm{d}#1}
usepackage[parfill]{parskip}
usepackage{listings}
usepackage{xcolor} % for setting colors
usepackage{breqn}

% set the default code style
lstset{
frame=tb, % draw a frame at the top and bottom of the code block
tabsize=4, % tab space width
showstringspaces=false, % don't mark spaces in strings
numbers=left, % display line numbers on the left
commentstyle=color{green}, % comment color
keywordstyle=color{blue}, % keyword color
stringstyle=color{red} % string color
}

begin{document}

section{$Delta A_2$ Derivation: Comparison with CRIS2}


First, let us start by showing the C++ code:
begin{lstlisting}[language=C++, caption={C++ code using listings}]
{
else if (evaltype == 5)
{
for (std::size_t i=startp;i<p.size();++i)
{
double & x = p[i].first; //input
double & y = p[i].second; //result
double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
double xi = crsxib(q1);
double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
p1i *= 4.3723240245*ab[0];
double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
}
}
}
end{lstlisting}









share|improve this question















marked as duplicate by Werner equations
Users with the  equations badge can single-handedly close equations questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 6 at 19:37


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















    up vote
    1
    down vote

    favorite













    This question already has an answer here:




    • lstlisting line wrapping

      1 answer




    I have a question about showing C++ code in LateX



    When I do the following, the C++ goes past the page. Is there a way to fix this?



    documentclass{article} 

    newcommand{dd}[1]{mathrm{d}#1}
    usepackage[parfill]{parskip}
    usepackage{listings}
    usepackage{xcolor} % for setting colors
    usepackage{breqn}

    % set the default code style
    lstset{
    frame=tb, % draw a frame at the top and bottom of the code block
    tabsize=4, % tab space width
    showstringspaces=false, % don't mark spaces in strings
    numbers=left, % display line numbers on the left
    commentstyle=color{green}, % comment color
    keywordstyle=color{blue}, % keyword color
    stringstyle=color{red} % string color
    }

    begin{document}

    section{$Delta A_2$ Derivation: Comparison with CRIS2}


    First, let us start by showing the C++ code:
    begin{lstlisting}[language=C++, caption={C++ code using listings}]
    {
    else if (evaltype == 5)
    {
    for (std::size_t i=startp;i<p.size();++i)
    {
    double & x = p[i].first; //input
    double & y = p[i].second; //result
    double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
    double xi = crsxib(q1);
    double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
    p1i *= 4.3723240245*ab[0];
    double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
    y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
    }
    }
    }
    end{lstlisting}









    share|improve this question















    marked as duplicate by Werner equations
    Users with the  equations badge can single-handedly close equations questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Dec 6 at 19:37


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite












      This question already has an answer here:




      • lstlisting line wrapping

        1 answer




      I have a question about showing C++ code in LateX



      When I do the following, the C++ goes past the page. Is there a way to fix this?



      documentclass{article} 

      newcommand{dd}[1]{mathrm{d}#1}
      usepackage[parfill]{parskip}
      usepackage{listings}
      usepackage{xcolor} % for setting colors
      usepackage{breqn}

      % set the default code style
      lstset{
      frame=tb, % draw a frame at the top and bottom of the code block
      tabsize=4, % tab space width
      showstringspaces=false, % don't mark spaces in strings
      numbers=left, % display line numbers on the left
      commentstyle=color{green}, % comment color
      keywordstyle=color{blue}, % keyword color
      stringstyle=color{red} % string color
      }

      begin{document}

      section{$Delta A_2$ Derivation: Comparison with CRIS2}


      First, let us start by showing the C++ code:
      begin{lstlisting}[language=C++, caption={C++ code using listings}]
      {
      else if (evaltype == 5)
      {
      for (std::size_t i=startp;i<p.size();++i)
      {
      double & x = p[i].first; //input
      double & y = p[i].second; //result
      double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
      double xi = crsxib(q1);
      double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
      p1i *= 4.3723240245*ab[0];
      double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
      y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
      }
      }
      }
      end{lstlisting}









      share|improve this question
















      This question already has an answer here:




      • lstlisting line wrapping

        1 answer




      I have a question about showing C++ code in LateX



      When I do the following, the C++ goes past the page. Is there a way to fix this?



      documentclass{article} 

      newcommand{dd}[1]{mathrm{d}#1}
      usepackage[parfill]{parskip}
      usepackage{listings}
      usepackage{xcolor} % for setting colors
      usepackage{breqn}

      % set the default code style
      lstset{
      frame=tb, % draw a frame at the top and bottom of the code block
      tabsize=4, % tab space width
      showstringspaces=false, % don't mark spaces in strings
      numbers=left, % display line numbers on the left
      commentstyle=color{green}, % comment color
      keywordstyle=color{blue}, % keyword color
      stringstyle=color{red} % string color
      }

      begin{document}

      section{$Delta A_2$ Derivation: Comparison with CRIS2}


      First, let us start by showing the C++ code:
      begin{lstlisting}[language=C++, caption={C++ code using listings}]
      {
      else if (evaltype == 5)
      {
      for (std::size_t i=startp;i<p.size();++i)
      {
      double & x = p[i].first; //input
      double & y = p[i].second; //result
      double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
      double xi = crsxib(q1);
      double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
      p1i *= 4.3723240245*ab[0];
      double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
      y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
      }
      }
      }
      end{lstlisting}




      This question already has an answer here:




      • lstlisting line wrapping

        1 answer








      equations






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 6 at 19:31









      zyy

      798613




      798613










      asked Dec 6 at 18:38









      Jackson Hart

      1224




      1224




      marked as duplicate by Werner equations
      Users with the  equations badge can single-handedly close equations questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Dec 6 at 19:37


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Werner equations
      Users with the  equations badge can single-handedly close equations questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Dec 6 at 19:37


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Please in your lstset add breaklines = true, then with



          begin{lstlisting}[language=C++, caption={C++ code using listings}]
          {
          else if (evaltype == 5)
          {
          for (std::size_t i=startp;i<p.size();++i)
          {
          double & x = p[i].first; //input
          double & y = p[i].second; //result
          double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
          double xi = crsxib(q1);
          double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
          p1i *= 4.3723240245*ab[0];
          double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
          y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
          }
          }
          }
          end{lstlisting}


          You will see




          cpp







          share|improve this answer




























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            Please in your lstset add breaklines = true, then with



            begin{lstlisting}[language=C++, caption={C++ code using listings}]
            {
            else if (evaltype == 5)
            {
            for (std::size_t i=startp;i<p.size();++i)
            {
            double & x = p[i].first; //input
            double & y = p[i].second; //result
            double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
            double xi = crsxib(q1);
            double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
            p1i *= 4.3723240245*ab[0];
            double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
            y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
            }
            }
            }
            end{lstlisting}


            You will see




            cpp







            share|improve this answer

























              up vote
              1
              down vote



              accepted










              Please in your lstset add breaklines = true, then with



              begin{lstlisting}[language=C++, caption={C++ code using listings}]
              {
              else if (evaltype == 5)
              {
              for (std::size_t i=startp;i<p.size();++i)
              {
              double & x = p[i].first; //input
              double & y = p[i].second; //result
              double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
              double xi = crsxib(q1);
              double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
              p1i *= 4.3723240245*ab[0];
              double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
              y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
              }
              }
              }
              end{lstlisting}


              You will see




              cpp







              share|improve this answer























                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                Please in your lstset add breaklines = true, then with



                begin{lstlisting}[language=C++, caption={C++ code using listings}]
                {
                else if (evaltype == 5)
                {
                for (std::size_t i=startp;i<p.size();++i)
                {
                double & x = p[i].first; //input
                double & y = p[i].second; //result
                double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
                double xi = crsxib(q1);
                double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
                p1i *= 4.3723240245*ab[0];
                double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
                y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
                }
                }
                }
                end{lstlisting}


                You will see




                cpp







                share|improve this answer












                Please in your lstset add breaklines = true, then with



                begin{lstlisting}[language=C++, caption={C++ code using listings}]
                {
                else if (evaltype == 5)
                {
                for (std::size_t i=startp;i<p.size();++i)
                {
                double & x = p[i].first; //input
                double & y = p[i].second; //result
                double q1 = rtx[8]-(cafdf(rtx[0],rtx[4]*x*x*x)-rtx[3])/rtx[1];
                double xi = crsxib(q1);
                double p1i = 23.0/(1.0-xi)+ab[5]+xi*(11.0*ab[2]+xi*(2.0*ab[3]+xi*33.0*ab[4]));
                p1i *= 4.3723240245*ab[0];
                double si = (1.0+ci*(ab[99]+xi*(ab[44]+xi*ab[33])))/(3.0*(1.0-xi));
                y = p1i*xi*xy/abc[2]/dde[2]*(x/(1.0+dd*(x-1.0)))*(q/(1.0+si*(x-1.0)))*(x/(1.0+ci*(x-1.0)));
                }
                }
                }
                end{lstlisting}


                You will see




                cpp








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 6 at 19:16









                zyy

                798613




                798613















                    Popular posts from this blog

                    Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                    ComboBox Display Member on multiple fields

                    Is it possible to collect Nectar points via Trainline?