Misplaced omit in table and {} at the end of a command











up vote
1
down vote

favorite












The following LaTeX document does not compile.



documentclass{article}

usepackage{booktabs}
usepackage{ltablex}
usepackage{multirow}
usepackage{lipsum}

begin{document}

noindent{}
begin{tabularx}{linewidth}{Xl}
bottomrule{}%
multicolumn{2}{c}{TESTING}\*midrule{}%
textbf{Left} & textbf{Right}\*toprule{}%
endfirsthead{}%
%
toprule{}%
multicolumn{2}{c}{emph{continuing}}\*midrule{}%
textbf{Left} & textbf{Right}\*bottomrule{}%
endhead{}%
%
lipsum[1][1-2] & first \midrule{}%
lipsum[2][1-2] & second \midrule{}%
lipsum[3][1-2] & third \midrule{}%
lipsum[4][1-2] & third \bottomrule{}%
end{tabularx}

end{document}


pdflatex is giving the error message:



! Misplaced omit.
multispan ->omit
@multispan
l.26 end{tabularx}


I have observed that if {}% is removed from the source, it compiles.



What is the explanation for this behaviour?



The real document I am working with is generated by a Haskell program using the HaTeX library, which uses to append {} to commands with no arguments.










share|improve this question


















  • 3




    omit must be the first token in a cell (probably after some expansions). Since {} is not expandable, omit is no longer the first token in that cell, hence the error about a misplaced omit. multicolumn expands to something with multispan as its first token and multispan expands to omit@multispan, so after two steps of expansion, multicolumn is turned into something with omit as the first token.
    – Skillmon
    Dec 7 at 13:35






  • 2




    Well, the Haskell program does wrong. The culprits are precisely those wrong {} tokens.
    – egreg
    Dec 7 at 13:40






  • 1




    Argumentless commands that produce text are in most occasions best followed by {}. Those that don't produce text should not have {} after them, but a simple space.
    – egreg
    Dec 7 at 14:01






  • 1




    In almost all cases, spaces are removed after all command names, i.e. control sequences that are built of a backslash followed by letters. Note that control characters like \, > etc. don't discard the following space(s).
    – siracusa
    Dec 7 at 16:34








  • 1




    @Romildo Yes, it's safe for commands whose name consists of letters. The only problem is if the command generates text. But it's quite rare and you Haskell program should not take that case as the general one. Commands to be protected that way can be added as exceptions.
    – egreg
    Dec 7 at 23:38

















up vote
1
down vote

favorite












The following LaTeX document does not compile.



documentclass{article}

usepackage{booktabs}
usepackage{ltablex}
usepackage{multirow}
usepackage{lipsum}

begin{document}

noindent{}
begin{tabularx}{linewidth}{Xl}
bottomrule{}%
multicolumn{2}{c}{TESTING}\*midrule{}%
textbf{Left} & textbf{Right}\*toprule{}%
endfirsthead{}%
%
toprule{}%
multicolumn{2}{c}{emph{continuing}}\*midrule{}%
textbf{Left} & textbf{Right}\*bottomrule{}%
endhead{}%
%
lipsum[1][1-2] & first \midrule{}%
lipsum[2][1-2] & second \midrule{}%
lipsum[3][1-2] & third \midrule{}%
lipsum[4][1-2] & third \bottomrule{}%
end{tabularx}

end{document}


pdflatex is giving the error message:



! Misplaced omit.
multispan ->omit
@multispan
l.26 end{tabularx}


I have observed that if {}% is removed from the source, it compiles.



What is the explanation for this behaviour?



The real document I am working with is generated by a Haskell program using the HaTeX library, which uses to append {} to commands with no arguments.










share|improve this question


















  • 3




    omit must be the first token in a cell (probably after some expansions). Since {} is not expandable, omit is no longer the first token in that cell, hence the error about a misplaced omit. multicolumn expands to something with multispan as its first token and multispan expands to omit@multispan, so after two steps of expansion, multicolumn is turned into something with omit as the first token.
    – Skillmon
    Dec 7 at 13:35






  • 2




    Well, the Haskell program does wrong. The culprits are precisely those wrong {} tokens.
    – egreg
    Dec 7 at 13:40






  • 1




    Argumentless commands that produce text are in most occasions best followed by {}. Those that don't produce text should not have {} after them, but a simple space.
    – egreg
    Dec 7 at 14:01






  • 1




    In almost all cases, spaces are removed after all command names, i.e. control sequences that are built of a backslash followed by letters. Note that control characters like \, > etc. don't discard the following space(s).
    – siracusa
    Dec 7 at 16:34








  • 1




    @Romildo Yes, it's safe for commands whose name consists of letters. The only problem is if the command generates text. But it's quite rare and you Haskell program should not take that case as the general one. Commands to be protected that way can be added as exceptions.
    – egreg
    Dec 7 at 23:38















up vote
1
down vote

favorite









up vote
1
down vote

favorite











The following LaTeX document does not compile.



documentclass{article}

usepackage{booktabs}
usepackage{ltablex}
usepackage{multirow}
usepackage{lipsum}

begin{document}

noindent{}
begin{tabularx}{linewidth}{Xl}
bottomrule{}%
multicolumn{2}{c}{TESTING}\*midrule{}%
textbf{Left} & textbf{Right}\*toprule{}%
endfirsthead{}%
%
toprule{}%
multicolumn{2}{c}{emph{continuing}}\*midrule{}%
textbf{Left} & textbf{Right}\*bottomrule{}%
endhead{}%
%
lipsum[1][1-2] & first \midrule{}%
lipsum[2][1-2] & second \midrule{}%
lipsum[3][1-2] & third \midrule{}%
lipsum[4][1-2] & third \bottomrule{}%
end{tabularx}

end{document}


pdflatex is giving the error message:



! Misplaced omit.
multispan ->omit
@multispan
l.26 end{tabularx}


I have observed that if {}% is removed from the source, it compiles.



What is the explanation for this behaviour?



The real document I am working with is generated by a Haskell program using the HaTeX library, which uses to append {} to commands with no arguments.










share|improve this question













The following LaTeX document does not compile.



documentclass{article}

usepackage{booktabs}
usepackage{ltablex}
usepackage{multirow}
usepackage{lipsum}

begin{document}

noindent{}
begin{tabularx}{linewidth}{Xl}
bottomrule{}%
multicolumn{2}{c}{TESTING}\*midrule{}%
textbf{Left} & textbf{Right}\*toprule{}%
endfirsthead{}%
%
toprule{}%
multicolumn{2}{c}{emph{continuing}}\*midrule{}%
textbf{Left} & textbf{Right}\*bottomrule{}%
endhead{}%
%
lipsum[1][1-2] & first \midrule{}%
lipsum[2][1-2] & second \midrule{}%
lipsum[3][1-2] & third \midrule{}%
lipsum[4][1-2] & third \bottomrule{}%
end{tabularx}

end{document}


pdflatex is giving the error message:



! Misplaced omit.
multispan ->omit
@multispan
l.26 end{tabularx}


I have observed that if {}% is removed from the source, it compiles.



What is the explanation for this behaviour?



The real document I am working with is generated by a Haskell program using the HaTeX library, which uses to append {} to commands with no arguments.







tables macros






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 7 at 13:28









Romildo

1,84832545




1,84832545








  • 3




    omit must be the first token in a cell (probably after some expansions). Since {} is not expandable, omit is no longer the first token in that cell, hence the error about a misplaced omit. multicolumn expands to something with multispan as its first token and multispan expands to omit@multispan, so after two steps of expansion, multicolumn is turned into something with omit as the first token.
    – Skillmon
    Dec 7 at 13:35






  • 2




    Well, the Haskell program does wrong. The culprits are precisely those wrong {} tokens.
    – egreg
    Dec 7 at 13:40






  • 1




    Argumentless commands that produce text are in most occasions best followed by {}. Those that don't produce text should not have {} after them, but a simple space.
    – egreg
    Dec 7 at 14:01






  • 1




    In almost all cases, spaces are removed after all command names, i.e. control sequences that are built of a backslash followed by letters. Note that control characters like \, > etc. don't discard the following space(s).
    – siracusa
    Dec 7 at 16:34








  • 1




    @Romildo Yes, it's safe for commands whose name consists of letters. The only problem is if the command generates text. But it's quite rare and you Haskell program should not take that case as the general one. Commands to be protected that way can be added as exceptions.
    – egreg
    Dec 7 at 23:38
















  • 3




    omit must be the first token in a cell (probably after some expansions). Since {} is not expandable, omit is no longer the first token in that cell, hence the error about a misplaced omit. multicolumn expands to something with multispan as its first token and multispan expands to omit@multispan, so after two steps of expansion, multicolumn is turned into something with omit as the first token.
    – Skillmon
    Dec 7 at 13:35






  • 2




    Well, the Haskell program does wrong. The culprits are precisely those wrong {} tokens.
    – egreg
    Dec 7 at 13:40






  • 1




    Argumentless commands that produce text are in most occasions best followed by {}. Those that don't produce text should not have {} after them, but a simple space.
    – egreg
    Dec 7 at 14:01






  • 1




    In almost all cases, spaces are removed after all command names, i.e. control sequences that are built of a backslash followed by letters. Note that control characters like \, > etc. don't discard the following space(s).
    – siracusa
    Dec 7 at 16:34








  • 1




    @Romildo Yes, it's safe for commands whose name consists of letters. The only problem is if the command generates text. But it's quite rare and you Haskell program should not take that case as the general one. Commands to be protected that way can be added as exceptions.
    – egreg
    Dec 7 at 23:38










3




3




omit must be the first token in a cell (probably after some expansions). Since {} is not expandable, omit is no longer the first token in that cell, hence the error about a misplaced omit. multicolumn expands to something with multispan as its first token and multispan expands to omit@multispan, so after two steps of expansion, multicolumn is turned into something with omit as the first token.
– Skillmon
Dec 7 at 13:35




omit must be the first token in a cell (probably after some expansions). Since {} is not expandable, omit is no longer the first token in that cell, hence the error about a misplaced omit. multicolumn expands to something with multispan as its first token and multispan expands to omit@multispan, so after two steps of expansion, multicolumn is turned into something with omit as the first token.
– Skillmon
Dec 7 at 13:35




2




2




Well, the Haskell program does wrong. The culprits are precisely those wrong {} tokens.
– egreg
Dec 7 at 13:40




Well, the Haskell program does wrong. The culprits are precisely those wrong {} tokens.
– egreg
Dec 7 at 13:40




1




1




Argumentless commands that produce text are in most occasions best followed by {}. Those that don't produce text should not have {} after them, but a simple space.
– egreg
Dec 7 at 14:01




Argumentless commands that produce text are in most occasions best followed by {}. Those that don't produce text should not have {} after them, but a simple space.
– egreg
Dec 7 at 14:01




1




1




In almost all cases, spaces are removed after all command names, i.e. control sequences that are built of a backslash followed by letters. Note that control characters like \, > etc. don't discard the following space(s).
– siracusa
Dec 7 at 16:34






In almost all cases, spaces are removed after all command names, i.e. control sequences that are built of a backslash followed by letters. Note that control characters like \, > etc. don't discard the following space(s).
– siracusa
Dec 7 at 16:34






1




1




@Romildo Yes, it's safe for commands whose name consists of letters. The only problem is if the command generates text. But it's quite rare and you Haskell program should not take that case as the general one. Commands to be protected that way can be added as exceptions.
– egreg
Dec 7 at 23:38






@Romildo Yes, it's safe for commands whose name consists of letters. The only problem is if the command generates text. But it's quite rare and you Haskell program should not take that case as the general one. Commands to be protected that way can be added as exceptions.
– egreg
Dec 7 at 23:38












1 Answer
1






active

oldest

votes

















up vote
3
down vote













The {} after noindent does not generate a TeX error, but the newline after it forces bad output, as the paragraph has been started prematurely the newline generates a non-discarded space at the start of the paragraph, which looks a bit like indentation but is not indented by a fixed parindent it is a word space.



Compare the two paragraphs:



enter image description here



documentclass{article}

begin{document}


noindent
AAA

noindent{}
AAA
end{document}




multicolumn must be first the command (after expansion) in its cell, any non expandable tokens will cause multicolumn to generate an error, as it is too late to change the cell template.



So the example could be simplified to



documentclass{article}

begin{document}


begin{tabular}{c}
a\
{}multicolumn{1}{l}{x}
end{tabular}

end{document}


which generates



! Misplaced omit.
multispan ->omit
@multispan
l.8 {}multicolumn{1}{l}{x}





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',
    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%2f463694%2fmisplaced-omit-in-table-and-at-the-end-of-a-command%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








    up vote
    3
    down vote













    The {} after noindent does not generate a TeX error, but the newline after it forces bad output, as the paragraph has been started prematurely the newline generates a non-discarded space at the start of the paragraph, which looks a bit like indentation but is not indented by a fixed parindent it is a word space.



    Compare the two paragraphs:



    enter image description here



    documentclass{article}

    begin{document}


    noindent
    AAA

    noindent{}
    AAA
    end{document}




    multicolumn must be first the command (after expansion) in its cell, any non expandable tokens will cause multicolumn to generate an error, as it is too late to change the cell template.



    So the example could be simplified to



    documentclass{article}

    begin{document}


    begin{tabular}{c}
    a\
    {}multicolumn{1}{l}{x}
    end{tabular}

    end{document}


    which generates



    ! Misplaced omit.
    multispan ->omit
    @multispan
    l.8 {}multicolumn{1}{l}{x}





    share|improve this answer

























      up vote
      3
      down vote













      The {} after noindent does not generate a TeX error, but the newline after it forces bad output, as the paragraph has been started prematurely the newline generates a non-discarded space at the start of the paragraph, which looks a bit like indentation but is not indented by a fixed parindent it is a word space.



      Compare the two paragraphs:



      enter image description here



      documentclass{article}

      begin{document}


      noindent
      AAA

      noindent{}
      AAA
      end{document}




      multicolumn must be first the command (after expansion) in its cell, any non expandable tokens will cause multicolumn to generate an error, as it is too late to change the cell template.



      So the example could be simplified to



      documentclass{article}

      begin{document}


      begin{tabular}{c}
      a\
      {}multicolumn{1}{l}{x}
      end{tabular}

      end{document}


      which generates



      ! Misplaced omit.
      multispan ->omit
      @multispan
      l.8 {}multicolumn{1}{l}{x}





      share|improve this answer























        up vote
        3
        down vote










        up vote
        3
        down vote









        The {} after noindent does not generate a TeX error, but the newline after it forces bad output, as the paragraph has been started prematurely the newline generates a non-discarded space at the start of the paragraph, which looks a bit like indentation but is not indented by a fixed parindent it is a word space.



        Compare the two paragraphs:



        enter image description here



        documentclass{article}

        begin{document}


        noindent
        AAA

        noindent{}
        AAA
        end{document}




        multicolumn must be first the command (after expansion) in its cell, any non expandable tokens will cause multicolumn to generate an error, as it is too late to change the cell template.



        So the example could be simplified to



        documentclass{article}

        begin{document}


        begin{tabular}{c}
        a\
        {}multicolumn{1}{l}{x}
        end{tabular}

        end{document}


        which generates



        ! Misplaced omit.
        multispan ->omit
        @multispan
        l.8 {}multicolumn{1}{l}{x}





        share|improve this answer












        The {} after noindent does not generate a TeX error, but the newline after it forces bad output, as the paragraph has been started prematurely the newline generates a non-discarded space at the start of the paragraph, which looks a bit like indentation but is not indented by a fixed parindent it is a word space.



        Compare the two paragraphs:



        enter image description here



        documentclass{article}

        begin{document}


        noindent
        AAA

        noindent{}
        AAA
        end{document}




        multicolumn must be first the command (after expansion) in its cell, any non expandable tokens will cause multicolumn to generate an error, as it is too late to change the cell template.



        So the example could be simplified to



        documentclass{article}

        begin{document}


        begin{tabular}{c}
        a\
        {}multicolumn{1}{l}{x}
        end{tabular}

        end{document}


        which generates



        ! Misplaced omit.
        multispan ->omit
        @multispan
        l.8 {}multicolumn{1}{l}{x}






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 7 at 22:38









        David Carlisle

        480k3811121848




        480k3811121848






























            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%2f463694%2fmisplaced-omit-in-table-and-at-the-end-of-a-command%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

            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?