LaTeX table floating problem












1















Table unnecessarily floats to next page. I want it to be placed where it is specified.



renewcommand{familydefault}{sfdefault}
usepackage{multirow}
usepackage{graphicx}
usepackage[scaled=1]{helvet}
usepackage[helvet]{sfmath}
usepackage{graphicx}
setcounter{chapter}{0}
frontmatter
usepackage{multicol}
setlength{columnsep}{1cm}
begin{document}
chapter{Exponents}
begin{multicols}{2}
renewcommand{theenumii}{Alph{enumii}}
begin{enumerate}
item
begin{table*}[!htbp]
begin{tabular}{cc|c|c|c|c}
cline{3-5}
& & multicolumn{3}{c|}{Course} &
\ cline{3-6}
& & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
{Total} \ hline
multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
end{tabular}
end{table*}
A group of tenth-grade students responded to a survey that asked which math
course they were currently enrolled in. The survey data were broken down as
she able above. Which of the following categories accounts for approximately
19 percent of all the survey respondents?
begin{enumerate}
item Females taking Geometry
item Females taking Algebra II
item Males taking Geometry
item Males taking Algebra I
end{enumerate}
item
Which of the following expressions is equivalent to
$ sqrt[3]{a}cdot a cdot sqrt[5]{a^2} $ for $a > 0$ ?
\
begin{enumerate}
item $a^frac{2}{15}$\
item $a^frac{6}{15}$\
item $a^frac{11}{15}$\
item $a^frac{26}{15}$\
end{enumerate}
item
$$ sqrt{16y^2} $$
If $x>0$, which of the following is equivalent to the given expression?\
begin{enumerate}
item $4y$\
item $4y^2$\
item $32y$\
item $32y^2$\
end{enumerate}
end{enumerate}
end{multicols}
end{document}









share|improve this question

























  • Your example doesn't use begin{table}, but you probably mean why doesn't that work where you have used tabular. The table environment is a "float" -- it is meant to be independent of the location where it is input, and can move around to where it fits best in the document (usually on the same or the next page), It doesn't make sense within a list since it will not end up where it is input. Using tabular is the best approach in this situation.

    – barbara beeton
    Feb 28 at 3:53











  • thanks for your prompt reply, can we fix the issue of overlapping table content

    – Praveen25488
    Feb 28 at 3:56








  • 1





    You haven't said what document class you're using, but presumably the table is wider than the column. Since you said that it does fit in a full-width page, you might want to enter it separately with table*, give it a caption and a label, and say "see Table ref{<label value>}" at the item.

    – barbara beeton
    Feb 28 at 4:03











  • If you want to use floats, do not use the multicol package but the twocolumn option in the document class. To fit the table in the column, use a smaller font inside the float (e.g.: tiny), and/or remove the perfectly useless column "Gender", or use a float for two columns (i.e.,table* instead of table).

    – Fran
    Feb 28 at 4:12






  • 2





    unrelated but all the \ around and inside the enumerate are wrong and should be removed, and $$ should not be used in latex and should be [...]

    – David Carlisle
    Feb 28 at 7:49
















1















Table unnecessarily floats to next page. I want it to be placed where it is specified.



renewcommand{familydefault}{sfdefault}
usepackage{multirow}
usepackage{graphicx}
usepackage[scaled=1]{helvet}
usepackage[helvet]{sfmath}
usepackage{graphicx}
setcounter{chapter}{0}
frontmatter
usepackage{multicol}
setlength{columnsep}{1cm}
begin{document}
chapter{Exponents}
begin{multicols}{2}
renewcommand{theenumii}{Alph{enumii}}
begin{enumerate}
item
begin{table*}[!htbp]
begin{tabular}{cc|c|c|c|c}
cline{3-5}
& & multicolumn{3}{c|}{Course} &
\ cline{3-6}
& & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
{Total} \ hline
multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
end{tabular}
end{table*}
A group of tenth-grade students responded to a survey that asked which math
course they were currently enrolled in. The survey data were broken down as
she able above. Which of the following categories accounts for approximately
19 percent of all the survey respondents?
begin{enumerate}
item Females taking Geometry
item Females taking Algebra II
item Males taking Geometry
item Males taking Algebra I
end{enumerate}
item
Which of the following expressions is equivalent to
$ sqrt[3]{a}cdot a cdot sqrt[5]{a^2} $ for $a > 0$ ?
\
begin{enumerate}
item $a^frac{2}{15}$\
item $a^frac{6}{15}$\
item $a^frac{11}{15}$\
item $a^frac{26}{15}$\
end{enumerate}
item
$$ sqrt{16y^2} $$
If $x>0$, which of the following is equivalent to the given expression?\
begin{enumerate}
item $4y$\
item $4y^2$\
item $32y$\
item $32y^2$\
end{enumerate}
end{enumerate}
end{multicols}
end{document}









share|improve this question

























  • Your example doesn't use begin{table}, but you probably mean why doesn't that work where you have used tabular. The table environment is a "float" -- it is meant to be independent of the location where it is input, and can move around to where it fits best in the document (usually on the same or the next page), It doesn't make sense within a list since it will not end up where it is input. Using tabular is the best approach in this situation.

    – barbara beeton
    Feb 28 at 3:53











  • thanks for your prompt reply, can we fix the issue of overlapping table content

    – Praveen25488
    Feb 28 at 3:56








  • 1





    You haven't said what document class you're using, but presumably the table is wider than the column. Since you said that it does fit in a full-width page, you might want to enter it separately with table*, give it a caption and a label, and say "see Table ref{<label value>}" at the item.

    – barbara beeton
    Feb 28 at 4:03











  • If you want to use floats, do not use the multicol package but the twocolumn option in the document class. To fit the table in the column, use a smaller font inside the float (e.g.: tiny), and/or remove the perfectly useless column "Gender", or use a float for two columns (i.e.,table* instead of table).

    – Fran
    Feb 28 at 4:12






  • 2





    unrelated but all the \ around and inside the enumerate are wrong and should be removed, and $$ should not be used in latex and should be [...]

    – David Carlisle
    Feb 28 at 7:49














1












1








1








Table unnecessarily floats to next page. I want it to be placed where it is specified.



renewcommand{familydefault}{sfdefault}
usepackage{multirow}
usepackage{graphicx}
usepackage[scaled=1]{helvet}
usepackage[helvet]{sfmath}
usepackage{graphicx}
setcounter{chapter}{0}
frontmatter
usepackage{multicol}
setlength{columnsep}{1cm}
begin{document}
chapter{Exponents}
begin{multicols}{2}
renewcommand{theenumii}{Alph{enumii}}
begin{enumerate}
item
begin{table*}[!htbp]
begin{tabular}{cc|c|c|c|c}
cline{3-5}
& & multicolumn{3}{c|}{Course} &
\ cline{3-6}
& & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
{Total} \ hline
multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
end{tabular}
end{table*}
A group of tenth-grade students responded to a survey that asked which math
course they were currently enrolled in. The survey data were broken down as
she able above. Which of the following categories accounts for approximately
19 percent of all the survey respondents?
begin{enumerate}
item Females taking Geometry
item Females taking Algebra II
item Males taking Geometry
item Males taking Algebra I
end{enumerate}
item
Which of the following expressions is equivalent to
$ sqrt[3]{a}cdot a cdot sqrt[5]{a^2} $ for $a > 0$ ?
\
begin{enumerate}
item $a^frac{2}{15}$\
item $a^frac{6}{15}$\
item $a^frac{11}{15}$\
item $a^frac{26}{15}$\
end{enumerate}
item
$$ sqrt{16y^2} $$
If $x>0$, which of the following is equivalent to the given expression?\
begin{enumerate}
item $4y$\
item $4y^2$\
item $32y$\
item $32y^2$\
end{enumerate}
end{enumerate}
end{multicols}
end{document}









share|improve this question
















Table unnecessarily floats to next page. I want it to be placed where it is specified.



renewcommand{familydefault}{sfdefault}
usepackage{multirow}
usepackage{graphicx}
usepackage[scaled=1]{helvet}
usepackage[helvet]{sfmath}
usepackage{graphicx}
setcounter{chapter}{0}
frontmatter
usepackage{multicol}
setlength{columnsep}{1cm}
begin{document}
chapter{Exponents}
begin{multicols}{2}
renewcommand{theenumii}{Alph{enumii}}
begin{enumerate}
item
begin{table*}[!htbp]
begin{tabular}{cc|c|c|c|c}
cline{3-5}
& & multicolumn{3}{c|}{Course} &
\ cline{3-6}
& & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
{Total} \ hline
multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
end{tabular}
end{table*}
A group of tenth-grade students responded to a survey that asked which math
course they were currently enrolled in. The survey data were broken down as
she able above. Which of the following categories accounts for approximately
19 percent of all the survey respondents?
begin{enumerate}
item Females taking Geometry
item Females taking Algebra II
item Males taking Geometry
item Males taking Algebra I
end{enumerate}
item
Which of the following expressions is equivalent to
$ sqrt[3]{a}cdot a cdot sqrt[5]{a^2} $ for $a > 0$ ?
\
begin{enumerate}
item $a^frac{2}{15}$\
item $a^frac{6}{15}$\
item $a^frac{11}{15}$\
item $a^frac{26}{15}$\
end{enumerate}
item
$$ sqrt{16y^2} $$
If $x>0$, which of the following is equivalent to the given expression?\
begin{enumerate}
item $4y$\
item $4y^2$\
item $32y$\
item $32y^2$\
end{enumerate}
end{enumerate}
end{multicols}
end{document}






tables floats






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 28 at 4:22







Praveen25488

















asked Feb 28 at 3:39









Praveen25488Praveen25488

83




83













  • Your example doesn't use begin{table}, but you probably mean why doesn't that work where you have used tabular. The table environment is a "float" -- it is meant to be independent of the location where it is input, and can move around to where it fits best in the document (usually on the same or the next page), It doesn't make sense within a list since it will not end up where it is input. Using tabular is the best approach in this situation.

    – barbara beeton
    Feb 28 at 3:53











  • thanks for your prompt reply, can we fix the issue of overlapping table content

    – Praveen25488
    Feb 28 at 3:56








  • 1





    You haven't said what document class you're using, but presumably the table is wider than the column. Since you said that it does fit in a full-width page, you might want to enter it separately with table*, give it a caption and a label, and say "see Table ref{<label value>}" at the item.

    – barbara beeton
    Feb 28 at 4:03











  • If you want to use floats, do not use the multicol package but the twocolumn option in the document class. To fit the table in the column, use a smaller font inside the float (e.g.: tiny), and/or remove the perfectly useless column "Gender", or use a float for two columns (i.e.,table* instead of table).

    – Fran
    Feb 28 at 4:12






  • 2





    unrelated but all the \ around and inside the enumerate are wrong and should be removed, and $$ should not be used in latex and should be [...]

    – David Carlisle
    Feb 28 at 7:49



















  • Your example doesn't use begin{table}, but you probably mean why doesn't that work where you have used tabular. The table environment is a "float" -- it is meant to be independent of the location where it is input, and can move around to where it fits best in the document (usually on the same or the next page), It doesn't make sense within a list since it will not end up where it is input. Using tabular is the best approach in this situation.

    – barbara beeton
    Feb 28 at 3:53











  • thanks for your prompt reply, can we fix the issue of overlapping table content

    – Praveen25488
    Feb 28 at 3:56








  • 1





    You haven't said what document class you're using, but presumably the table is wider than the column. Since you said that it does fit in a full-width page, you might want to enter it separately with table*, give it a caption and a label, and say "see Table ref{<label value>}" at the item.

    – barbara beeton
    Feb 28 at 4:03











  • If you want to use floats, do not use the multicol package but the twocolumn option in the document class. To fit the table in the column, use a smaller font inside the float (e.g.: tiny), and/or remove the perfectly useless column "Gender", or use a float for two columns (i.e.,table* instead of table).

    – Fran
    Feb 28 at 4:12






  • 2





    unrelated but all the \ around and inside the enumerate are wrong and should be removed, and $$ should not be used in latex and should be [...]

    – David Carlisle
    Feb 28 at 7:49

















Your example doesn't use begin{table}, but you probably mean why doesn't that work where you have used tabular. The table environment is a "float" -- it is meant to be independent of the location where it is input, and can move around to where it fits best in the document (usually on the same or the next page), It doesn't make sense within a list since it will not end up where it is input. Using tabular is the best approach in this situation.

– barbara beeton
Feb 28 at 3:53





Your example doesn't use begin{table}, but you probably mean why doesn't that work where you have used tabular. The table environment is a "float" -- it is meant to be independent of the location where it is input, and can move around to where it fits best in the document (usually on the same or the next page), It doesn't make sense within a list since it will not end up where it is input. Using tabular is the best approach in this situation.

– barbara beeton
Feb 28 at 3:53













thanks for your prompt reply, can we fix the issue of overlapping table content

– Praveen25488
Feb 28 at 3:56







thanks for your prompt reply, can we fix the issue of overlapping table content

– Praveen25488
Feb 28 at 3:56






1




1





You haven't said what document class you're using, but presumably the table is wider than the column. Since you said that it does fit in a full-width page, you might want to enter it separately with table*, give it a caption and a label, and say "see Table ref{<label value>}" at the item.

– barbara beeton
Feb 28 at 4:03





You haven't said what document class you're using, but presumably the table is wider than the column. Since you said that it does fit in a full-width page, you might want to enter it separately with table*, give it a caption and a label, and say "see Table ref{<label value>}" at the item.

– barbara beeton
Feb 28 at 4:03













If you want to use floats, do not use the multicol package but the twocolumn option in the document class. To fit the table in the column, use a smaller font inside the float (e.g.: tiny), and/or remove the perfectly useless column "Gender", or use a float for two columns (i.e.,table* instead of table).

– Fran
Feb 28 at 4:12





If you want to use floats, do not use the multicol package but the twocolumn option in the document class. To fit the table in the column, use a smaller font inside the float (e.g.: tiny), and/or remove the perfectly useless column "Gender", or use a float for two columns (i.e.,table* instead of table).

– Fran
Feb 28 at 4:12




2




2





unrelated but all the \ around and inside the enumerate are wrong and should be removed, and $$ should not be used in latex and should be [...]

– David Carlisle
Feb 28 at 7:49





unrelated but all the \ around and inside the enumerate are wrong and should be removed, and $$ should not be used in latex and should be [...]

– David Carlisle
Feb 28 at 7:49










1 Answer
1






active

oldest

votes


















3














My answer focuses one just one aspect of your posting: How to make the tabular material fit inside the width of a column.



You haven't indicated which document class, which font size, or which page and text block dimensions you employ. The following solutioin may thus not fully meet your formatting needs. If it does not, feel free provide more details regarding the missing pieces of information.



The following screenshot shows both your original tabular environment, with lots and lots of vertical and horizontal lines, as well as a proposed new tabular* environment. The former is obviously much wider than columnwidth. The latter environment takes up much less horizontal space, mainly because it gets by with 5 instead of 6 columns. Conversely, the newly proposed solution (a) aligns the numbers on their respective (implicit) decimal markers and (b) strives to provide a much more "open" look, mainly by omitting all vertical lines and employing fewer, but well-spaced horizontal lines. The second solution also aims to provide an informative caption.



enter image description here



documentclass[twocolumn]{article}  % ?
renewcommand{familydefault}{sfdefault}
usepackage{booktabs,siunitx,multirow}
usepackage[skip=0.333baselineskip]{caption} % optional
begin{document}

begin{table}

caption{Original solution}
begin{tabular}{cc|c|c|c|c}
cline{3-5}
& & multicolumn{3}{c|}{Course} &
\ cline{3-6}
& & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
{Total} \ hline
multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
end{tabular}

vspace{1cm}

caption{Student enrolments, by gender and course}
setlengthtabcolsep{0pt} % make LaTeX figure out amount of inter-column whitespace
begin{tabular*}{columnwidth}{@{extracolsep{fill}}l *{4}{S[table-format=3.0]}}
toprule
Gender & multicolumn{3}{c}{Course} & {Total} \
cmidrule{2-4}
& {Algebra I} & {Geometry} & {Algebra II} \
midrule
Female & 35 & 53 & 62 & 150 \
Male & 44 & 59 & 57 & 160 \
addlinespace
Total & 79 &112 & 119 & 310 \
bottomrule
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%2f477079%2flatex-table-floating-problem%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









    3














    My answer focuses one just one aspect of your posting: How to make the tabular material fit inside the width of a column.



    You haven't indicated which document class, which font size, or which page and text block dimensions you employ. The following solutioin may thus not fully meet your formatting needs. If it does not, feel free provide more details regarding the missing pieces of information.



    The following screenshot shows both your original tabular environment, with lots and lots of vertical and horizontal lines, as well as a proposed new tabular* environment. The former is obviously much wider than columnwidth. The latter environment takes up much less horizontal space, mainly because it gets by with 5 instead of 6 columns. Conversely, the newly proposed solution (a) aligns the numbers on their respective (implicit) decimal markers and (b) strives to provide a much more "open" look, mainly by omitting all vertical lines and employing fewer, but well-spaced horizontal lines. The second solution also aims to provide an informative caption.



    enter image description here



    documentclass[twocolumn]{article}  % ?
    renewcommand{familydefault}{sfdefault}
    usepackage{booktabs,siunitx,multirow}
    usepackage[skip=0.333baselineskip]{caption} % optional
    begin{document}

    begin{table}

    caption{Original solution}
    begin{tabular}{cc|c|c|c|c}
    cline{3-5}
    & & multicolumn{3}{c|}{Course} &
    \ cline{3-6}
    & & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
    {Total} \ hline
    multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
    multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
    multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
    end{tabular}

    vspace{1cm}

    caption{Student enrolments, by gender and course}
    setlengthtabcolsep{0pt} % make LaTeX figure out amount of inter-column whitespace
    begin{tabular*}{columnwidth}{@{extracolsep{fill}}l *{4}{S[table-format=3.0]}}
    toprule
    Gender & multicolumn{3}{c}{Course} & {Total} \
    cmidrule{2-4}
    & {Algebra I} & {Geometry} & {Algebra II} \
    midrule
    Female & 35 & 53 & 62 & 150 \
    Male & 44 & 59 & 57 & 160 \
    addlinespace
    Total & 79 &112 & 119 & 310 \
    bottomrule
    end{tabular*}

    end{table}
    end{document}





    share|improve this answer




























      3














      My answer focuses one just one aspect of your posting: How to make the tabular material fit inside the width of a column.



      You haven't indicated which document class, which font size, or which page and text block dimensions you employ. The following solutioin may thus not fully meet your formatting needs. If it does not, feel free provide more details regarding the missing pieces of information.



      The following screenshot shows both your original tabular environment, with lots and lots of vertical and horizontal lines, as well as a proposed new tabular* environment. The former is obviously much wider than columnwidth. The latter environment takes up much less horizontal space, mainly because it gets by with 5 instead of 6 columns. Conversely, the newly proposed solution (a) aligns the numbers on their respective (implicit) decimal markers and (b) strives to provide a much more "open" look, mainly by omitting all vertical lines and employing fewer, but well-spaced horizontal lines. The second solution also aims to provide an informative caption.



      enter image description here



      documentclass[twocolumn]{article}  % ?
      renewcommand{familydefault}{sfdefault}
      usepackage{booktabs,siunitx,multirow}
      usepackage[skip=0.333baselineskip]{caption} % optional
      begin{document}

      begin{table}

      caption{Original solution}
      begin{tabular}{cc|c|c|c|c}
      cline{3-5}
      & & multicolumn{3}{c|}{Course} &
      \ cline{3-6}
      & & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
      {Total} \ hline
      multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
      multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
      multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
      end{tabular}

      vspace{1cm}

      caption{Student enrolments, by gender and course}
      setlengthtabcolsep{0pt} % make LaTeX figure out amount of inter-column whitespace
      begin{tabular*}{columnwidth}{@{extracolsep{fill}}l *{4}{S[table-format=3.0]}}
      toprule
      Gender & multicolumn{3}{c}{Course} & {Total} \
      cmidrule{2-4}
      & {Algebra I} & {Geometry} & {Algebra II} \
      midrule
      Female & 35 & 53 & 62 & 150 \
      Male & 44 & 59 & 57 & 160 \
      addlinespace
      Total & 79 &112 & 119 & 310 \
      bottomrule
      end{tabular*}

      end{table}
      end{document}





      share|improve this answer


























        3












        3








        3







        My answer focuses one just one aspect of your posting: How to make the tabular material fit inside the width of a column.



        You haven't indicated which document class, which font size, or which page and text block dimensions you employ. The following solutioin may thus not fully meet your formatting needs. If it does not, feel free provide more details regarding the missing pieces of information.



        The following screenshot shows both your original tabular environment, with lots and lots of vertical and horizontal lines, as well as a proposed new tabular* environment. The former is obviously much wider than columnwidth. The latter environment takes up much less horizontal space, mainly because it gets by with 5 instead of 6 columns. Conversely, the newly proposed solution (a) aligns the numbers on their respective (implicit) decimal markers and (b) strives to provide a much more "open" look, mainly by omitting all vertical lines and employing fewer, but well-spaced horizontal lines. The second solution also aims to provide an informative caption.



        enter image description here



        documentclass[twocolumn]{article}  % ?
        renewcommand{familydefault}{sfdefault}
        usepackage{booktabs,siunitx,multirow}
        usepackage[skip=0.333baselineskip]{caption} % optional
        begin{document}

        begin{table}

        caption{Original solution}
        begin{tabular}{cc|c|c|c|c}
        cline{3-5}
        & & multicolumn{3}{c|}{Course} &
        \ cline{3-6}
        & & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
        {Total} \ hline
        multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
        multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
        multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
        end{tabular}

        vspace{1cm}

        caption{Student enrolments, by gender and course}
        setlengthtabcolsep{0pt} % make LaTeX figure out amount of inter-column whitespace
        begin{tabular*}{columnwidth}{@{extracolsep{fill}}l *{4}{S[table-format=3.0]}}
        toprule
        Gender & multicolumn{3}{c}{Course} & {Total} \
        cmidrule{2-4}
        & {Algebra I} & {Geometry} & {Algebra II} \
        midrule
        Female & 35 & 53 & 62 & 150 \
        Male & 44 & 59 & 57 & 160 \
        addlinespace
        Total & 79 &112 & 119 & 310 \
        bottomrule
        end{tabular*}

        end{table}
        end{document}





        share|improve this answer













        My answer focuses one just one aspect of your posting: How to make the tabular material fit inside the width of a column.



        You haven't indicated which document class, which font size, or which page and text block dimensions you employ. The following solutioin may thus not fully meet your formatting needs. If it does not, feel free provide more details regarding the missing pieces of information.



        The following screenshot shows both your original tabular environment, with lots and lots of vertical and horizontal lines, as well as a proposed new tabular* environment. The former is obviously much wider than columnwidth. The latter environment takes up much less horizontal space, mainly because it gets by with 5 instead of 6 columns. Conversely, the newly proposed solution (a) aligns the numbers on their respective (implicit) decimal markers and (b) strives to provide a much more "open" look, mainly by omitting all vertical lines and employing fewer, but well-spaced horizontal lines. The second solution also aims to provide an informative caption.



        enter image description here



        documentclass[twocolumn]{article}  % ?
        renewcommand{familydefault}{sfdefault}
        usepackage{booktabs,siunitx,multirow}
        usepackage[skip=0.333baselineskip]{caption} % optional
        begin{document}

        begin{table}

        caption{Original solution}
        begin{tabular}{cc|c|c|c|c}
        cline{3-5}
        & & multicolumn{3}{c|}{Course} &
        \ cline{3-6}
        & & Algebra I & Geometry & Algebra II & multicolumn{1}{c|}
        {Total} \ hline
        multicolumn{1}{|c|}{multirow{2}{*}{Gender}} & Female & 35 & 53 & 62 & multicolumn{1}{c|}{150} \ cline{2-6}
        multicolumn{1}{|c|}{} & Male & 44 & 59 & 57 & multicolumn{1}{c|}{160} \ hline
        multicolumn{2}{|c|}{Total} & 79 & 112 & 119 & multicolumn{1}{c|}{310} \ hline
        end{tabular}

        vspace{1cm}

        caption{Student enrolments, by gender and course}
        setlengthtabcolsep{0pt} % make LaTeX figure out amount of inter-column whitespace
        begin{tabular*}{columnwidth}{@{extracolsep{fill}}l *{4}{S[table-format=3.0]}}
        toprule
        Gender & multicolumn{3}{c}{Course} & {Total} \
        cmidrule{2-4}
        & {Algebra I} & {Geometry} & {Algebra II} \
        midrule
        Female & 35 & 53 & 62 & 150 \
        Male & 44 & 59 & 57 & 160 \
        addlinespace
        Total & 79 &112 & 119 & 310 \
        bottomrule
        end{tabular*}

        end{table}
        end{document}






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 28 at 9:06









        MicoMico

        282k31385774




        282k31385774






























            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%2f477079%2flatex-table-floating-problem%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?