How to make table with column lines only in the first row












2















How do I draw my table with the column lines only in the first row? Here's a MWE of my code:



documentclass[12pt,a4paper]{article}

usepackage[utf8]{inputenc}
usepackage{float}
usepackage[table]{xcolor}

begin{document}
begin{table}[H]
centering
caption{Data of subways in Fortal city}
rowcolors{1}{gray!20}{white}
begin{tabular}{c|c|c|c}
hline
Line & Extension & Stations & Vehicle type \
hline
South & 24,1 km & 19 & Electric \
West & 19,5 km & 10 & VLT a diesel \
Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
East & 7,3 km & 11 & VLT a diesel \
hline
end{tabular}
end{table}
end{document}


What I'd like to achieve:



table with column lines only in the first row










share|improve this question




















  • 2





    multicolumn{1}{c|}{Line} ...

    – John Kormylo
    Mar 19 at 15:46






  • 2





    Related: tex.stackexchange.com/a/36803/156344

    – JouleV
    Mar 19 at 15:48











  • Thank you, guys. That helped a lot!

    – Levy
    Mar 19 at 17:01






  • 1





    @JohnKormylo Would you like to add an answer?

    – CarLaTeX
    Mar 20 at 6:09











  • @CarLaTeX I'll post my answer with the help of them.

    – Levy
    Mar 20 at 15:39
















2















How do I draw my table with the column lines only in the first row? Here's a MWE of my code:



documentclass[12pt,a4paper]{article}

usepackage[utf8]{inputenc}
usepackage{float}
usepackage[table]{xcolor}

begin{document}
begin{table}[H]
centering
caption{Data of subways in Fortal city}
rowcolors{1}{gray!20}{white}
begin{tabular}{c|c|c|c}
hline
Line & Extension & Stations & Vehicle type \
hline
South & 24,1 km & 19 & Electric \
West & 19,5 km & 10 & VLT a diesel \
Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
East & 7,3 km & 11 & VLT a diesel \
hline
end{tabular}
end{table}
end{document}


What I'd like to achieve:



table with column lines only in the first row










share|improve this question




















  • 2





    multicolumn{1}{c|}{Line} ...

    – John Kormylo
    Mar 19 at 15:46






  • 2





    Related: tex.stackexchange.com/a/36803/156344

    – JouleV
    Mar 19 at 15:48











  • Thank you, guys. That helped a lot!

    – Levy
    Mar 19 at 17:01






  • 1





    @JohnKormylo Would you like to add an answer?

    – CarLaTeX
    Mar 20 at 6:09











  • @CarLaTeX I'll post my answer with the help of them.

    – Levy
    Mar 20 at 15:39














2












2








2


0






How do I draw my table with the column lines only in the first row? Here's a MWE of my code:



documentclass[12pt,a4paper]{article}

usepackage[utf8]{inputenc}
usepackage{float}
usepackage[table]{xcolor}

begin{document}
begin{table}[H]
centering
caption{Data of subways in Fortal city}
rowcolors{1}{gray!20}{white}
begin{tabular}{c|c|c|c}
hline
Line & Extension & Stations & Vehicle type \
hline
South & 24,1 km & 19 & Electric \
West & 19,5 km & 10 & VLT a diesel \
Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
East & 7,3 km & 11 & VLT a diesel \
hline
end{tabular}
end{table}
end{document}


What I'd like to achieve:



table with column lines only in the first row










share|improve this question
















How do I draw my table with the column lines only in the first row? Here's a MWE of my code:



documentclass[12pt,a4paper]{article}

usepackage[utf8]{inputenc}
usepackage{float}
usepackage[table]{xcolor}

begin{document}
begin{table}[H]
centering
caption{Data of subways in Fortal city}
rowcolors{1}{gray!20}{white}
begin{tabular}{c|c|c|c}
hline
Line & Extension & Stations & Vehicle type \
hline
South & 24,1 km & 19 & Electric \
West & 19,5 km & 10 & VLT a diesel \
Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
East & 7,3 km & 11 & VLT a diesel \
hline
end{tabular}
end{table}
end{document}


What I'd like to achieve:



table with column lines only in the first row







tables columns






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 20 at 15:46







Levy

















asked Mar 19 at 15:41









LevyLevy

413312




413312








  • 2





    multicolumn{1}{c|}{Line} ...

    – John Kormylo
    Mar 19 at 15:46






  • 2





    Related: tex.stackexchange.com/a/36803/156344

    – JouleV
    Mar 19 at 15:48











  • Thank you, guys. That helped a lot!

    – Levy
    Mar 19 at 17:01






  • 1





    @JohnKormylo Would you like to add an answer?

    – CarLaTeX
    Mar 20 at 6:09











  • @CarLaTeX I'll post my answer with the help of them.

    – Levy
    Mar 20 at 15:39














  • 2





    multicolumn{1}{c|}{Line} ...

    – John Kormylo
    Mar 19 at 15:46






  • 2





    Related: tex.stackexchange.com/a/36803/156344

    – JouleV
    Mar 19 at 15:48











  • Thank you, guys. That helped a lot!

    – Levy
    Mar 19 at 17:01






  • 1





    @JohnKormylo Would you like to add an answer?

    – CarLaTeX
    Mar 20 at 6:09











  • @CarLaTeX I'll post my answer with the help of them.

    – Levy
    Mar 20 at 15:39








2




2





multicolumn{1}{c|}{Line} ...

– John Kormylo
Mar 19 at 15:46





multicolumn{1}{c|}{Line} ...

– John Kormylo
Mar 19 at 15:46




2




2





Related: tex.stackexchange.com/a/36803/156344

– JouleV
Mar 19 at 15:48





Related: tex.stackexchange.com/a/36803/156344

– JouleV
Mar 19 at 15:48













Thank you, guys. That helped a lot!

– Levy
Mar 19 at 17:01





Thank you, guys. That helped a lot!

– Levy
Mar 19 at 17:01




1




1





@JohnKormylo Would you like to add an answer?

– CarLaTeX
Mar 20 at 6:09





@JohnKormylo Would you like to add an answer?

– CarLaTeX
Mar 20 at 6:09













@CarLaTeX I'll post my answer with the help of them.

– Levy
Mar 20 at 15:39





@CarLaTeX I'll post my answer with the help of them.

– Levy
Mar 20 at 15:39










1 Answer
1






active

oldest

votes


















1














It's an easy trick using the multicol package. I removed the columns in my tabular agument but I drew them back, only in the header, using multicolumn{1}{c|}{text}



Here's the full working code:



documentclass[12pt,a4paper]{article}

usepackage[utf8]{inputenc}
usepackage{float}
usepackage[table]{xcolor}
usepackage{multicol}

begin{document}
begin{table}[H]
centering
caption{Data of subways in Fortal city}
rowcolors{1}{gray!20}{white}
begin{tabular}{cccc}
hline
multicolumn{1}{c|}{Line} & multicolumn{1}{c|}{Extension} & multicolumn{1}{c|}{Stations} & Vehicle type \
hline
South & 24,1 km & 19 & Electric \
West & 19,5 km & 10 & VLT a diesel \
Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
East & 7,3 km & 11 & VLT a diesel \
hline
end{tabular}
end{table}
end{document}


Notice that for this particular problem I don't need to draw a column c| in the last column. Otherwise it'd turned into a border, which I don't want to happen.



Furthermore, to avoid always writing multicolumn{1}{c|}{text} I defined a new command topr{} as newcommand{topr}[1]{multicolumn{1}{c|}{#1}} which spare me to write fixed values. So the improved code turned out like this:



documentclass[12pt,a4paper]{article}

usepackage[utf8]{inputenc}
usepackage{float}
usepackage[table]{xcolor}
usepackage{multicol}
newcommand{topr}[1]{multicolumn{1}{c|}{#1}}

begin{document}
begin{table}[H]
centering
caption{Data of subways in Fortal city}
rowcolors{1}{gray!20}{white}
begin{tabular}{cccc}
hline
topr{Line} & topr{Extension} & topr{Stations} & Vehicle type \
hline
South & 24,1 km & 19 & Electric \
West & 19,5 km & 10 & VLT a diesel \
Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
East & 7,3 km & 11 & VLT a diesel \
hline
end{tabular}
end{table}
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%2f480306%2fhow-to-make-table-with-column-lines-only-in-the-first-row%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









    1














    It's an easy trick using the multicol package. I removed the columns in my tabular agument but I drew them back, only in the header, using multicolumn{1}{c|}{text}



    Here's the full working code:



    documentclass[12pt,a4paper]{article}

    usepackage[utf8]{inputenc}
    usepackage{float}
    usepackage[table]{xcolor}
    usepackage{multicol}

    begin{document}
    begin{table}[H]
    centering
    caption{Data of subways in Fortal city}
    rowcolors{1}{gray!20}{white}
    begin{tabular}{cccc}
    hline
    multicolumn{1}{c|}{Line} & multicolumn{1}{c|}{Extension} & multicolumn{1}{c|}{Stations} & Vehicle type \
    hline
    South & 24,1 km & 19 & Electric \
    West & 19,5 km & 10 & VLT a diesel \
    Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
    East & 7,3 km & 11 & VLT a diesel \
    hline
    end{tabular}
    end{table}
    end{document}


    Notice that for this particular problem I don't need to draw a column c| in the last column. Otherwise it'd turned into a border, which I don't want to happen.



    Furthermore, to avoid always writing multicolumn{1}{c|}{text} I defined a new command topr{} as newcommand{topr}[1]{multicolumn{1}{c|}{#1}} which spare me to write fixed values. So the improved code turned out like this:



    documentclass[12pt,a4paper]{article}

    usepackage[utf8]{inputenc}
    usepackage{float}
    usepackage[table]{xcolor}
    usepackage{multicol}
    newcommand{topr}[1]{multicolumn{1}{c|}{#1}}

    begin{document}
    begin{table}[H]
    centering
    caption{Data of subways in Fortal city}
    rowcolors{1}{gray!20}{white}
    begin{tabular}{cccc}
    hline
    topr{Line} & topr{Extension} & topr{Stations} & Vehicle type \
    hline
    South & 24,1 km & 19 & Electric \
    West & 19,5 km & 10 & VLT a diesel \
    Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
    East & 7,3 km & 11 & VLT a diesel \
    hline
    end{tabular}
    end{table}
    end{document}





    share|improve this answer






























      1














      It's an easy trick using the multicol package. I removed the columns in my tabular agument but I drew them back, only in the header, using multicolumn{1}{c|}{text}



      Here's the full working code:



      documentclass[12pt,a4paper]{article}

      usepackage[utf8]{inputenc}
      usepackage{float}
      usepackage[table]{xcolor}
      usepackage{multicol}

      begin{document}
      begin{table}[H]
      centering
      caption{Data of subways in Fortal city}
      rowcolors{1}{gray!20}{white}
      begin{tabular}{cccc}
      hline
      multicolumn{1}{c|}{Line} & multicolumn{1}{c|}{Extension} & multicolumn{1}{c|}{Stations} & Vehicle type \
      hline
      South & 24,1 km & 19 & Electric \
      West & 19,5 km & 10 & VLT a diesel \
      Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
      East & 7,3 km & 11 & VLT a diesel \
      hline
      end{tabular}
      end{table}
      end{document}


      Notice that for this particular problem I don't need to draw a column c| in the last column. Otherwise it'd turned into a border, which I don't want to happen.



      Furthermore, to avoid always writing multicolumn{1}{c|}{text} I defined a new command topr{} as newcommand{topr}[1]{multicolumn{1}{c|}{#1}} which spare me to write fixed values. So the improved code turned out like this:



      documentclass[12pt,a4paper]{article}

      usepackage[utf8]{inputenc}
      usepackage{float}
      usepackage[table]{xcolor}
      usepackage{multicol}
      newcommand{topr}[1]{multicolumn{1}{c|}{#1}}

      begin{document}
      begin{table}[H]
      centering
      caption{Data of subways in Fortal city}
      rowcolors{1}{gray!20}{white}
      begin{tabular}{cccc}
      hline
      topr{Line} & topr{Extension} & topr{Stations} & Vehicle type \
      hline
      South & 24,1 km & 19 & Electric \
      West & 19,5 km & 10 & VLT a diesel \
      Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
      East & 7,3 km & 11 & VLT a diesel \
      hline
      end{tabular}
      end{table}
      end{document}





      share|improve this answer




























        1












        1








        1







        It's an easy trick using the multicol package. I removed the columns in my tabular agument but I drew them back, only in the header, using multicolumn{1}{c|}{text}



        Here's the full working code:



        documentclass[12pt,a4paper]{article}

        usepackage[utf8]{inputenc}
        usepackage{float}
        usepackage[table]{xcolor}
        usepackage{multicol}

        begin{document}
        begin{table}[H]
        centering
        caption{Data of subways in Fortal city}
        rowcolors{1}{gray!20}{white}
        begin{tabular}{cccc}
        hline
        multicolumn{1}{c|}{Line} & multicolumn{1}{c|}{Extension} & multicolumn{1}{c|}{Stations} & Vehicle type \
        hline
        South & 24,1 km & 19 & Electric \
        West & 19,5 km & 10 & VLT a diesel \
        Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
        East & 7,3 km & 11 & VLT a diesel \
        hline
        end{tabular}
        end{table}
        end{document}


        Notice that for this particular problem I don't need to draw a column c| in the last column. Otherwise it'd turned into a border, which I don't want to happen.



        Furthermore, to avoid always writing multicolumn{1}{c|}{text} I defined a new command topr{} as newcommand{topr}[1]{multicolumn{1}{c|}{#1}} which spare me to write fixed values. So the improved code turned out like this:



        documentclass[12pt,a4paper]{article}

        usepackage[utf8]{inputenc}
        usepackage{float}
        usepackage[table]{xcolor}
        usepackage{multicol}
        newcommand{topr}[1]{multicolumn{1}{c|}{#1}}

        begin{document}
        begin{table}[H]
        centering
        caption{Data of subways in Fortal city}
        rowcolors{1}{gray!20}{white}
        begin{tabular}{cccc}
        hline
        topr{Line} & topr{Extension} & topr{Stations} & Vehicle type \
        hline
        South & 24,1 km & 19 & Electric \
        West & 19,5 km & 10 & VLT a diesel \
        Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
        East & 7,3 km & 11 & VLT a diesel \
        hline
        end{tabular}
        end{table}
        end{document}





        share|improve this answer















        It's an easy trick using the multicol package. I removed the columns in my tabular agument but I drew them back, only in the header, using multicolumn{1}{c|}{text}



        Here's the full working code:



        documentclass[12pt,a4paper]{article}

        usepackage[utf8]{inputenc}
        usepackage{float}
        usepackage[table]{xcolor}
        usepackage{multicol}

        begin{document}
        begin{table}[H]
        centering
        caption{Data of subways in Fortal city}
        rowcolors{1}{gray!20}{white}
        begin{tabular}{cccc}
        hline
        multicolumn{1}{c|}{Line} & multicolumn{1}{c|}{Extension} & multicolumn{1}{c|}{Stations} & Vehicle type \
        hline
        South & 24,1 km & 19 & Electric \
        West & 19,5 km & 10 & VLT a diesel \
        Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
        East & 7,3 km & 11 & VLT a diesel \
        hline
        end{tabular}
        end{table}
        end{document}


        Notice that for this particular problem I don't need to draw a column c| in the last column. Otherwise it'd turned into a border, which I don't want to happen.



        Furthermore, to avoid always writing multicolumn{1}{c|}{text} I defined a new command topr{} as newcommand{topr}[1]{multicolumn{1}{c|}{#1}} which spare me to write fixed values. So the improved code turned out like this:



        documentclass[12pt,a4paper]{article}

        usepackage[utf8]{inputenc}
        usepackage{float}
        usepackage[table]{xcolor}
        usepackage{multicol}
        newcommand{topr}[1]{multicolumn{1}{c|}{#1}}

        begin{document}
        begin{table}[H]
        centering
        caption{Data of subways in Fortal city}
        rowcolors{1}{gray!20}{white}
        begin{tabular}{cccc}
        hline
        topr{Line} & topr{Extension} & topr{Stations} & Vehicle type \
        hline
        South & 24,1 km & 19 & Electric \
        West & 19,5 km & 10 & VLT a diesel \
        Parangaba-Mucuripe & 13,2 km & 10 & VLT a diesel \
        East & 7,3 km & 11 & VLT a diesel \
        hline
        end{tabular}
        end{table}
        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 20 at 15:47

























        answered Mar 20 at 15:40









        LevyLevy

        413312




        413312






























            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%2f480306%2fhow-to-make-table-with-column-lines-only-in-the-first-row%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

            How to change which sound is reproduced for terminal bell?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Can I use Tabulator js library in my java Spring + Thymeleaf project?