Siunitx: Wrong parse in S-column tabular












3















Multiple uses of a text file containing numbers include a representation in a table. I read the file line by line and save those in a macro for a later use in a table. I use the S-column specifier of siunitx to format those numbers. Unfortunately, the occasionally present exponents are not parsed, i.e. the mantissa is parsed, but the exponents still remain in the output with some space.



If I explicitely use num{line} instead, all is done perfectly (except, commas are not placed below each other). So, what's wrong here?



$pdflatex -shell-escape main.tex 
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)


Minimal example:



 documentclass{article}
usepackage{siunitx}
sisetup{
locale = DE,
round-precision=6,
table-format=1.6e+1,
round-mode=places,
}

makeatletter
newreadinfile
defpreparetable#1{
@bsphack
bgroup
openininfile=#1
let\=relax
newcountlinecnt
gdefusetable{}
endlinechar=-1
@whileswunlessifeofinfilefi{%
advancelinecnt by @ne
readlineinfile to line
ifrelaxlinerelaxelse
xdefusetable{usetable thelinecnt & line \}
fi
}
egroup
@esphack
}
makeatother

begin{document}
begin{tabular}{cS}
Schritt & {Fehler} \
preparetable{test.test}
usetable
end{tabular}
end{document}


and an example file:



    0.37159
0.026349
1.1273e-04
1.8199e-09
4.0825e-17









share|improve this question





























    3















    Multiple uses of a text file containing numbers include a representation in a table. I read the file line by line and save those in a macro for a later use in a table. I use the S-column specifier of siunitx to format those numbers. Unfortunately, the occasionally present exponents are not parsed, i.e. the mantissa is parsed, but the exponents still remain in the output with some space.



    If I explicitely use num{line} instead, all is done perfectly (except, commas are not placed below each other). So, what's wrong here?



    $pdflatex -shell-escape main.tex 
    This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)


    Minimal example:



     documentclass{article}
    usepackage{siunitx}
    sisetup{
    locale = DE,
    round-precision=6,
    table-format=1.6e+1,
    round-mode=places,
    }

    makeatletter
    newreadinfile
    defpreparetable#1{
    @bsphack
    bgroup
    openininfile=#1
    let\=relax
    newcountlinecnt
    gdefusetable{}
    endlinechar=-1
    @whileswunlessifeofinfilefi{%
    advancelinecnt by @ne
    readlineinfile to line
    ifrelaxlinerelaxelse
    xdefusetable{usetable thelinecnt & line \}
    fi
    }
    egroup
    @esphack
    }
    makeatother

    begin{document}
    begin{tabular}{cS}
    Schritt & {Fehler} \
    preparetable{test.test}
    usetable
    end{tabular}
    end{document}


    and an example file:



        0.37159
    0.026349
    1.1273e-04
    1.8199e-09
    4.0825e-17









    share|improve this question



























      3












      3








      3








      Multiple uses of a text file containing numbers include a representation in a table. I read the file line by line and save those in a macro for a later use in a table. I use the S-column specifier of siunitx to format those numbers. Unfortunately, the occasionally present exponents are not parsed, i.e. the mantissa is parsed, but the exponents still remain in the output with some space.



      If I explicitely use num{line} instead, all is done perfectly (except, commas are not placed below each other). So, what's wrong here?



      $pdflatex -shell-escape main.tex 
      This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)


      Minimal example:



       documentclass{article}
      usepackage{siunitx}
      sisetup{
      locale = DE,
      round-precision=6,
      table-format=1.6e+1,
      round-mode=places,
      }

      makeatletter
      newreadinfile
      defpreparetable#1{
      @bsphack
      bgroup
      openininfile=#1
      let\=relax
      newcountlinecnt
      gdefusetable{}
      endlinechar=-1
      @whileswunlessifeofinfilefi{%
      advancelinecnt by @ne
      readlineinfile to line
      ifrelaxlinerelaxelse
      xdefusetable{usetable thelinecnt & line \}
      fi
      }
      egroup
      @esphack
      }
      makeatother

      begin{document}
      begin{tabular}{cS}
      Schritt & {Fehler} \
      preparetable{test.test}
      usetable
      end{tabular}
      end{document}


      and an example file:



          0.37159
      0.026349
      1.1273e-04
      1.8199e-09
      4.0825e-17









      share|improve this question
















      Multiple uses of a text file containing numbers include a representation in a table. I read the file line by line and save those in a macro for a later use in a table. I use the S-column specifier of siunitx to format those numbers. Unfortunately, the occasionally present exponents are not parsed, i.e. the mantissa is parsed, but the exponents still remain in the output with some space.



      If I explicitely use num{line} instead, all is done perfectly (except, commas are not placed below each other). So, what's wrong here?



      $pdflatex -shell-escape main.tex 
      This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)


      Minimal example:



       documentclass{article}
      usepackage{siunitx}
      sisetup{
      locale = DE,
      round-precision=6,
      table-format=1.6e+1,
      round-mode=places,
      }

      makeatletter
      newreadinfile
      defpreparetable#1{
      @bsphack
      bgroup
      openininfile=#1
      let\=relax
      newcountlinecnt
      gdefusetable{}
      endlinechar=-1
      @whileswunlessifeofinfilefi{%
      advancelinecnt by @ne
      readlineinfile to line
      ifrelaxlinerelaxelse
      xdefusetable{usetable thelinecnt & line \}
      fi
      }
      egroup
      @esphack
      }
      makeatother

      begin{document}
      begin{tabular}{cS}
      Schritt & {Fehler} \
      preparetable{test.test}
      usetable
      end{tabular}
      end{document}


      and an example file:



          0.37159
      0.026349
      1.1273e-04
      1.8199e-09
      4.0825e-17






      siunitx






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 3 hours ago







      camelCase

















      asked 3 hours ago









      camelCasecamelCase

      406




      406






















          1 Answer
          1






          active

          oldest

          votes


















          4














          You should use read and not readline, which assigns the wrong category code to e. You also had many spurious spaces in the preparetable macro definition.



          begin{filecontents*}{jobname.dat}
          0.37159
          0.026349
          1.1273e-04
          1.8199e-09
          4.0825e-17
          end{filecontents*}

          documentclass{article}
          usepackage{siunitx}
          sisetup{
          locale = DE,
          round-precision=6,
          table-format=1.6e+2,
          round-mode=places,
          }

          makeatletter
          newreadinfile
          defpreparetable#1{%
          @bsphack
          bgroup
          openininfile=#1relax
          let\=relax
          newcountlinecnt
          gdefusetable{}%
          endlinechar=-1
          @whileswunlessifeofinfilefi{%
          advancelinecnt by @ne
          readinfile to line
          ifrelaxlinerelaxelse
          xdefusetable{usetable thelinecnt & line \}%
          fi
          }%
          egroup
          @esphack
          }
          makeatother

          begin{document}
          begin{tabular}{cS}
          Schritt & {Fehler} \
          preparetable{jobname.dat}
          usetable
          end{tabular}
          end{document}


          enter image description here



          The mandatory expl3 version:



          begin{filecontents*}{jobname.dat}
          0.37159
          0.026349
          1.1273e-04
          1.8199e-09
          4.0825e-17
          end{filecontents*}

          documentclass{article}
          usepackage{siunitx}

          sisetup{
          locale = DE,
          round-precision=6,
          table-format=1.6e+2,
          round-mode=places,
          }

          ExplSyntaxOn
          NewDocumentCommand{maketable}{m}
          {
          camelcase_table_make:n { #1 }
          }

          tl_new:N g_camelcase_table_body_tl
          tl_new:N l__camelcase_table_entry_tl
          int_new:N l_camelcase_table_row_int
          ior_new:N g_camelcase_table_stream

          cs_new_protected:Nn camelcase_table_make:n
          {
          int_zero:N l_camelcase_table_row_int
          ior_open:Nn g_camelcase_table_stream { #1 }
          tl_build_gbegin:N g_camelcase_table_body_tl
          ior_map_variable:NNn g_camelcase_table_stream l__camelcase_table_entry_tl
          {
          int_incr:N l_camelcase_table_row_int
          tl_build_gput_right:Nx g_camelcase_table_body_tl
          {
          int_to_arabic:n { l_camelcase_table_row_int }
          &
          exp_not:V l__camelcase_table_entry_tl
          exp_not:N \
          }
          }
          tl_build_gend:N g_camelcase_table_body_tl
          tl_use:N g_camelcase_table_body_tl
          }
          ExplSyntaxOff

          begin{document}
          begin{tabular}{cS}
          Schritt & {Fehler} \
          maketable{jobname.dat}
          end{tabular}
          end{document}





          share|improve this answer

























            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%2f470565%2fsiunitx-wrong-parse-in-s-column-tabular%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            You should use read and not readline, which assigns the wrong category code to e. You also had many spurious spaces in the preparetable macro definition.



            begin{filecontents*}{jobname.dat}
            0.37159
            0.026349
            1.1273e-04
            1.8199e-09
            4.0825e-17
            end{filecontents*}

            documentclass{article}
            usepackage{siunitx}
            sisetup{
            locale = DE,
            round-precision=6,
            table-format=1.6e+2,
            round-mode=places,
            }

            makeatletter
            newreadinfile
            defpreparetable#1{%
            @bsphack
            bgroup
            openininfile=#1relax
            let\=relax
            newcountlinecnt
            gdefusetable{}%
            endlinechar=-1
            @whileswunlessifeofinfilefi{%
            advancelinecnt by @ne
            readinfile to line
            ifrelaxlinerelaxelse
            xdefusetable{usetable thelinecnt & line \}%
            fi
            }%
            egroup
            @esphack
            }
            makeatother

            begin{document}
            begin{tabular}{cS}
            Schritt & {Fehler} \
            preparetable{jobname.dat}
            usetable
            end{tabular}
            end{document}


            enter image description here



            The mandatory expl3 version:



            begin{filecontents*}{jobname.dat}
            0.37159
            0.026349
            1.1273e-04
            1.8199e-09
            4.0825e-17
            end{filecontents*}

            documentclass{article}
            usepackage{siunitx}

            sisetup{
            locale = DE,
            round-precision=6,
            table-format=1.6e+2,
            round-mode=places,
            }

            ExplSyntaxOn
            NewDocumentCommand{maketable}{m}
            {
            camelcase_table_make:n { #1 }
            }

            tl_new:N g_camelcase_table_body_tl
            tl_new:N l__camelcase_table_entry_tl
            int_new:N l_camelcase_table_row_int
            ior_new:N g_camelcase_table_stream

            cs_new_protected:Nn camelcase_table_make:n
            {
            int_zero:N l_camelcase_table_row_int
            ior_open:Nn g_camelcase_table_stream { #1 }
            tl_build_gbegin:N g_camelcase_table_body_tl
            ior_map_variable:NNn g_camelcase_table_stream l__camelcase_table_entry_tl
            {
            int_incr:N l_camelcase_table_row_int
            tl_build_gput_right:Nx g_camelcase_table_body_tl
            {
            int_to_arabic:n { l_camelcase_table_row_int }
            &
            exp_not:V l__camelcase_table_entry_tl
            exp_not:N \
            }
            }
            tl_build_gend:N g_camelcase_table_body_tl
            tl_use:N g_camelcase_table_body_tl
            }
            ExplSyntaxOff

            begin{document}
            begin{tabular}{cS}
            Schritt & {Fehler} \
            maketable{jobname.dat}
            end{tabular}
            end{document}





            share|improve this answer






























              4














              You should use read and not readline, which assigns the wrong category code to e. You also had many spurious spaces in the preparetable macro definition.



              begin{filecontents*}{jobname.dat}
              0.37159
              0.026349
              1.1273e-04
              1.8199e-09
              4.0825e-17
              end{filecontents*}

              documentclass{article}
              usepackage{siunitx}
              sisetup{
              locale = DE,
              round-precision=6,
              table-format=1.6e+2,
              round-mode=places,
              }

              makeatletter
              newreadinfile
              defpreparetable#1{%
              @bsphack
              bgroup
              openininfile=#1relax
              let\=relax
              newcountlinecnt
              gdefusetable{}%
              endlinechar=-1
              @whileswunlessifeofinfilefi{%
              advancelinecnt by @ne
              readinfile to line
              ifrelaxlinerelaxelse
              xdefusetable{usetable thelinecnt & line \}%
              fi
              }%
              egroup
              @esphack
              }
              makeatother

              begin{document}
              begin{tabular}{cS}
              Schritt & {Fehler} \
              preparetable{jobname.dat}
              usetable
              end{tabular}
              end{document}


              enter image description here



              The mandatory expl3 version:



              begin{filecontents*}{jobname.dat}
              0.37159
              0.026349
              1.1273e-04
              1.8199e-09
              4.0825e-17
              end{filecontents*}

              documentclass{article}
              usepackage{siunitx}

              sisetup{
              locale = DE,
              round-precision=6,
              table-format=1.6e+2,
              round-mode=places,
              }

              ExplSyntaxOn
              NewDocumentCommand{maketable}{m}
              {
              camelcase_table_make:n { #1 }
              }

              tl_new:N g_camelcase_table_body_tl
              tl_new:N l__camelcase_table_entry_tl
              int_new:N l_camelcase_table_row_int
              ior_new:N g_camelcase_table_stream

              cs_new_protected:Nn camelcase_table_make:n
              {
              int_zero:N l_camelcase_table_row_int
              ior_open:Nn g_camelcase_table_stream { #1 }
              tl_build_gbegin:N g_camelcase_table_body_tl
              ior_map_variable:NNn g_camelcase_table_stream l__camelcase_table_entry_tl
              {
              int_incr:N l_camelcase_table_row_int
              tl_build_gput_right:Nx g_camelcase_table_body_tl
              {
              int_to_arabic:n { l_camelcase_table_row_int }
              &
              exp_not:V l__camelcase_table_entry_tl
              exp_not:N \
              }
              }
              tl_build_gend:N g_camelcase_table_body_tl
              tl_use:N g_camelcase_table_body_tl
              }
              ExplSyntaxOff

              begin{document}
              begin{tabular}{cS}
              Schritt & {Fehler} \
              maketable{jobname.dat}
              end{tabular}
              end{document}





              share|improve this answer




























                4












                4








                4







                You should use read and not readline, which assigns the wrong category code to e. You also had many spurious spaces in the preparetable macro definition.



                begin{filecontents*}{jobname.dat}
                0.37159
                0.026349
                1.1273e-04
                1.8199e-09
                4.0825e-17
                end{filecontents*}

                documentclass{article}
                usepackage{siunitx}
                sisetup{
                locale = DE,
                round-precision=6,
                table-format=1.6e+2,
                round-mode=places,
                }

                makeatletter
                newreadinfile
                defpreparetable#1{%
                @bsphack
                bgroup
                openininfile=#1relax
                let\=relax
                newcountlinecnt
                gdefusetable{}%
                endlinechar=-1
                @whileswunlessifeofinfilefi{%
                advancelinecnt by @ne
                readinfile to line
                ifrelaxlinerelaxelse
                xdefusetable{usetable thelinecnt & line \}%
                fi
                }%
                egroup
                @esphack
                }
                makeatother

                begin{document}
                begin{tabular}{cS}
                Schritt & {Fehler} \
                preparetable{jobname.dat}
                usetable
                end{tabular}
                end{document}


                enter image description here



                The mandatory expl3 version:



                begin{filecontents*}{jobname.dat}
                0.37159
                0.026349
                1.1273e-04
                1.8199e-09
                4.0825e-17
                end{filecontents*}

                documentclass{article}
                usepackage{siunitx}

                sisetup{
                locale = DE,
                round-precision=6,
                table-format=1.6e+2,
                round-mode=places,
                }

                ExplSyntaxOn
                NewDocumentCommand{maketable}{m}
                {
                camelcase_table_make:n { #1 }
                }

                tl_new:N g_camelcase_table_body_tl
                tl_new:N l__camelcase_table_entry_tl
                int_new:N l_camelcase_table_row_int
                ior_new:N g_camelcase_table_stream

                cs_new_protected:Nn camelcase_table_make:n
                {
                int_zero:N l_camelcase_table_row_int
                ior_open:Nn g_camelcase_table_stream { #1 }
                tl_build_gbegin:N g_camelcase_table_body_tl
                ior_map_variable:NNn g_camelcase_table_stream l__camelcase_table_entry_tl
                {
                int_incr:N l_camelcase_table_row_int
                tl_build_gput_right:Nx g_camelcase_table_body_tl
                {
                int_to_arabic:n { l_camelcase_table_row_int }
                &
                exp_not:V l__camelcase_table_entry_tl
                exp_not:N \
                }
                }
                tl_build_gend:N g_camelcase_table_body_tl
                tl_use:N g_camelcase_table_body_tl
                }
                ExplSyntaxOff

                begin{document}
                begin{tabular}{cS}
                Schritt & {Fehler} \
                maketable{jobname.dat}
                end{tabular}
                end{document}





                share|improve this answer















                You should use read and not readline, which assigns the wrong category code to e. You also had many spurious spaces in the preparetable macro definition.



                begin{filecontents*}{jobname.dat}
                0.37159
                0.026349
                1.1273e-04
                1.8199e-09
                4.0825e-17
                end{filecontents*}

                documentclass{article}
                usepackage{siunitx}
                sisetup{
                locale = DE,
                round-precision=6,
                table-format=1.6e+2,
                round-mode=places,
                }

                makeatletter
                newreadinfile
                defpreparetable#1{%
                @bsphack
                bgroup
                openininfile=#1relax
                let\=relax
                newcountlinecnt
                gdefusetable{}%
                endlinechar=-1
                @whileswunlessifeofinfilefi{%
                advancelinecnt by @ne
                readinfile to line
                ifrelaxlinerelaxelse
                xdefusetable{usetable thelinecnt & line \}%
                fi
                }%
                egroup
                @esphack
                }
                makeatother

                begin{document}
                begin{tabular}{cS}
                Schritt & {Fehler} \
                preparetable{jobname.dat}
                usetable
                end{tabular}
                end{document}


                enter image description here



                The mandatory expl3 version:



                begin{filecontents*}{jobname.dat}
                0.37159
                0.026349
                1.1273e-04
                1.8199e-09
                4.0825e-17
                end{filecontents*}

                documentclass{article}
                usepackage{siunitx}

                sisetup{
                locale = DE,
                round-precision=6,
                table-format=1.6e+2,
                round-mode=places,
                }

                ExplSyntaxOn
                NewDocumentCommand{maketable}{m}
                {
                camelcase_table_make:n { #1 }
                }

                tl_new:N g_camelcase_table_body_tl
                tl_new:N l__camelcase_table_entry_tl
                int_new:N l_camelcase_table_row_int
                ior_new:N g_camelcase_table_stream

                cs_new_protected:Nn camelcase_table_make:n
                {
                int_zero:N l_camelcase_table_row_int
                ior_open:Nn g_camelcase_table_stream { #1 }
                tl_build_gbegin:N g_camelcase_table_body_tl
                ior_map_variable:NNn g_camelcase_table_stream l__camelcase_table_entry_tl
                {
                int_incr:N l_camelcase_table_row_int
                tl_build_gput_right:Nx g_camelcase_table_body_tl
                {
                int_to_arabic:n { l_camelcase_table_row_int }
                &
                exp_not:V l__camelcase_table_entry_tl
                exp_not:N \
                }
                }
                tl_build_gend:N g_camelcase_table_body_tl
                tl_use:N g_camelcase_table_body_tl
                }
                ExplSyntaxOff

                begin{document}
                begin{tabular}{cS}
                Schritt & {Fehler} \
                maketable{jobname.dat}
                end{tabular}
                end{document}






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 3 hours ago

























                answered 3 hours ago









                egregegreg

                713k8618933182




                713k8618933182






























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f470565%2fsiunitx-wrong-parse-in-s-column-tabular%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

                    Polycentropodidae

                    Magento 2 Error message: Invalid state change requested

                    Paulmy