Specifying minimal (not fixed) width in tabularUse column-separator & (ampersand) inside...

How to set path in STY file as relative to this file path

The reduction of NAD+

What kind of inflection is occuring in passive vb + かかった?

Why won't the strings command stop?

Being asked to review a paper in conference one has submitted to

Split a number into equal parts given the number of parts

Are there other characters in the Star Wars universe who had damaged bodies and needed to wear an outfit like Darth Vader?

Ahoy, Ye Traveler!

What is better: yes / no radio, or simple checkbox?

How can I handle a player who pre-plans arguments about my rulings on RAW?

How do I deal with being envious of my own players?

Where is this quote about overcoming the impossible said in "Interstellar"?

Convert an array of objects to array of the objects' values

Specific Chinese carabiner QA?

Why did the Cray-1 have 8 parity bits per word?

Can I solder 12/2 Romex to extend wire 5 ft?

Is there any relevance to Thor getting his hair cut other than comedic value?

A bug in Excel? Conditional formatting for marking duplicates also highlights unique value

Is there a full canon version of Tyrion's jackass/honeycomb joke?

How to kill a localhost:8080

Formatting a table to look nice

How do we objectively assess if a dialogue sounds unnatural or cringy?

GPL code private and stolen

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?



Specifying minimal (not fixed) width in tabular


Use column-separator & (ampersand) inside newenvironmentFixed-width interword spaceKnow the cell width with tabular* or include a paragraph box without specifying its widthSelective alignment tabs in tabular/array?Fixed table width with even alignmentTabular and grid typesettingTabular columns have different widthTabular fixed widthcolumn width specifyingHow to set longtable width to text width so that the text in cell wraps around automatically?













10















I want some columns in my tables to have a minimal column width, that should always be maintained, even if the content is smaller, but increased when the content is wider.



Bounty-related update: @Sandy G's answer produces the desired behavior, but I want it to be a column type so that I can specify it like this:



documentclass{article}
begin{document}
begin{tabular}{m{2cm}m{2cm}m{1cm}m{1cm}}
Longer entry here&2&3&4\
5&6&Longer entry here&8
end{tabular}
end{document}









share|improve this question

















This question has an open bounty worth +50
reputation from sheß ending in 6 days.


This question has not received enough attention.


Bounty will be awarded to the answer that manages (or comes closest) to cast this into a column-type that can be specified like similar to begin{tabular}{p{3cm}





















    10















    I want some columns in my tables to have a minimal column width, that should always be maintained, even if the content is smaller, but increased when the content is wider.



    Bounty-related update: @Sandy G's answer produces the desired behavior, but I want it to be a column type so that I can specify it like this:



    documentclass{article}
    begin{document}
    begin{tabular}{m{2cm}m{2cm}m{1cm}m{1cm}}
    Longer entry here&2&3&4\
    5&6&Longer entry here&8
    end{tabular}
    end{document}









    share|improve this question

















    This question has an open bounty worth +50
    reputation from sheß ending in 6 days.


    This question has not received enough attention.


    Bounty will be awarded to the answer that manages (or comes closest) to cast this into a column-type that can be specified like similar to begin{tabular}{p{3cm}



















      10












      10








      10


      1






      I want some columns in my tables to have a minimal column width, that should always be maintained, even if the content is smaller, but increased when the content is wider.



      Bounty-related update: @Sandy G's answer produces the desired behavior, but I want it to be a column type so that I can specify it like this:



      documentclass{article}
      begin{document}
      begin{tabular}{m{2cm}m{2cm}m{1cm}m{1cm}}
      Longer entry here&2&3&4\
      5&6&Longer entry here&8
      end{tabular}
      end{document}









      share|improve this question
















      I want some columns in my tables to have a minimal column width, that should always be maintained, even if the content is smaller, but increased when the content is wider.



      Bounty-related update: @Sandy G's answer produces the desired behavior, but I want it to be a column type so that I can specify it like this:



      documentclass{article}
      begin{document}
      begin{tabular}{m{2cm}m{2cm}m{1cm}m{1cm}}
      Longer entry here&2&3&4\
      5&6&Longer entry here&8
      end{tabular}
      end{document}






      tables spacing columns






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 19 hours ago







      sheß

















      asked Nov 21 '17 at 17:04









      sheßsheß

      2,04611432




      2,04611432






      This question has an open bounty worth +50
      reputation from sheß ending in 6 days.


      This question has not received enough attention.


      Bounty will be awarded to the answer that manages (or comes closest) to cast this into a column-type that can be specified like similar to begin{tabular}{p{3cm}








      This question has an open bounty worth +50
      reputation from sheß ending in 6 days.


      This question has not received enough attention.


      Bounty will be awarded to the answer that manages (or comes closest) to cast this into a column-type that can be specified like similar to begin{tabular}{p{3cm}
























          4 Answers
          4






          active

          oldest

          votes


















          6














          See ADDENDUM and BONUS



          First, the original approach.



          Here is a newcolumntype solution, except that, for a reason that I should know but I don't, it won't work in the last column of the tabular. I'm sure David C. could tell me off the cuff why.



          So I've provided C{}, L{}, and R{} column types for specifying a minimum width, and an Q column type to use for a phantom, to get around the deficiency I initially cited.



          documentclass{article}
          usepackage{tabularx,stackengine}
          newcolumntype{L}[1]{>{minwd l{#1}}l<{endminwd}}
          newcolumntype{C}[1]{>{minwd c{#1}}c<{endminwd}}
          newcolumntype{R}[1]{>{minwd r{#1}}r<{endminwd}}
          defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
          newcolumntype{Q}{@{}c@{}}
          begin{document}
          begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|l|}
          a & a& b& c\
          aaaaaaaaaaaaaaaaa& aa& bb& cc\
          end{tabular}
          bigskip


          begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|Q}
          a & a& b& c&\
          aaaaaaaaaaaaaaaaa& aa& bb& cc&\
          end{tabular}
          end{document}


          enter image description here





          ADDENDUM



          Apparently the way to overcome the deficiency I noted in my original solution is to use collectcell:



          documentclass{article}
          usepackage{tabularx,stackengine,collcell}
          letendminwdrelax
          newcolumntype{L}[1]{>{collectcellxminwd l{#1}}l<{endminwdendcollectcell}}
          newcolumntype{C}[1]{>{collectcellxminwd c{#1}}c<{endminwdendcollectcell}}
          newcolumntype{R}[1]{>{collectcellxminwd r{#1}}r<{endminwdendcollectcell}}
          defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
          newcommandxminwd[1]{minwd#1}
          begin{document}
          begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|}
          a & a& b& c\
          aaaaaaaaaaaaaaaaa& aa& bb& cc\
          end{tabular}
          end{document}


          enter image description here



          And just for fun, if you set the vertical measure of the rule to something nonzero, say 1pt, you can see how the rule comes into play:



          enter image description here





          BONUS



          I realized the technique could be used for creating a D column for aligning a specified number of trailing decimal places. EDITED to handle decimal free inputs.



          documentclass{article}
          usepackage{tabularx,stackengine,collcell}
          letendecmrelax
          newcolumntype{D}[1]{>{collectcellDecm l{#1}}r<{..endDecmendcollectcell}}
          defdecm#1#2#3.#4.#5endDecm{#3.stackengine{0pt}{#4}{rule{#2wd0}{0pt}}{O}{#1}{F}{F}{L}}
          newcommandDecm[1]{setbox0=hbox{0}decm#1}
          begin{document}
          begin{tabular}{|D{3}|D{2}|D{4}|}
          10.345 & 410.34 & 1310.34\
          10 & 11 & 12.\
          210.34 & 1210.3 & 310.3456\
          end{tabular}
          end{document}


          enter image description here






          share|improve this answer

































            11














            This could be done by placing a row of 0pt rules with a negative row separator (for proper vertical alignment).



            enter image description here



            In the example, columns 1 and 2 have minimum width 2cm, while columns 3 and 4 have minimum width 1cm.



            documentclass{article}

            begin{document}
            [
            begin{tabular}{cccc}
            rule{2cm}{0pt}&rule{2cm}{0pt}&rule{1cm}{0pt}&rule{1cm}{0pt}\[-arraystretchnormalbaselineskip]]
            Longer entry here&2&3&4\
            5&6&Longer entry here&8
            end{tabular}
            ]
            end{document}


            Update:
            By placing the rule in a macro, you can adjust the fixed minimum in the document body similarly to a column type.



            enter image description here



            Here is the code:



            documentclass{article}

            newcommand{fixedmin}[1]{rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}\[-arraystretchnormalbaselineskip]}

            begin{document}

            noindent Here is a table with fixed minimum width 2 cm.
            [
            begin{tabular}{cccc}fixedmin{2cm}
            Longer entry here&2&3&4\
            5&6&Longer entry here&8
            end{tabular}
            ]

            noindent Here is a table with fixed minimum width 1 cm.
            [
            begin{tabular}{cccc}fixedmin{1cm}
            Longer entry here&2&3&4\
            5&6&Longer entry here&8
            end{tabular}
            ]

            noindent Here is a table with no fixed minimum width.
            [
            begin{tabular}{cccc}
            Longer entry here&2&3&4\
            5&6&Longer entry here&8
            end{tabular}
            ]

            end{document}





            share|improve this answer





















            • 2





              Great. Is there an easy way to make this a column type?

              – sheß
              Nov 22 '17 at 7:22











            • Nice update. I still hope though that someone will find a way to make this a columntype

              – sheß
              20 hours ago











            • That's a nice low-tech solution.

              – Circumscribe
              16 hours ago



















            7














            Here's a way to do it using the collcell package. The idea is to measure the content of the cell and then add rules to make up the deficit where appropriate. I've made versions for c, r and l columns. The vertical lines are just there to show the fixed width columns.



            documentclass{article}
            usepackage{array,calc,collcell}
            newlength{fwlen}
            newcolumntype{C}[1]{>{setlength{fwlen}{#1}collectcellfixedCwidth}c<{endcollectcell}}
            newcolumntype{R}[1]{>{setlength{fwlen}{#1}collectcellfixedRwidth}r<{endcollectcell}}
            newcolumntype{L}[1]{>{setlength{fwlen}{#1}collectcellfixedLwidth}l<{endcollectcell}}
            makeatletter
            newcommand{fixedCwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{(fwlen-@tempdima)/2}rule{@tempdimb}{0pt}#1rule{@tempdimb}{0pt}fi}
            newcommand{fixedLwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}#1rule{@tempdimb}{0pt}fi}
            newcommand{fixedRwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}rule{@tempdimb}{0pt}#1fi}
            makeatother
            begin{document}


            begin{tabular}{|C{1cm}|L{1cm}|R{1cm}|C{1cm}|C{1cm}|}
            123 & 123 & 123 & 123 & This is a wider column\
            5 & 6 & 6 & 8 & 8
            end{tabular}

            end{document}


            output of cod






            share|improve this answer































              2














              To do it properly, you need a minimum width and a maximum width of each column. You required the minimum width in your question. I'd say, it is better to have a maximum width, because otherwise your tabular might run out of the margin.



              documentclass{article}
              usepackage{array}
              usepackage{varwidth}% varwidth defines a new column type V.

              begin{document}
              begin{tabular}{*{4}{V{4cm}}}
              hspace*{2cm} & hspace*{2cm} & hspace*{1cm} & hspace*{1cm}\[-1em]
              Longer entry here&2&3&4\
              5&6&Longer entry here, which gets wrapped finaly&8\
              end{tabular}
              end{document}


              There are to small tricks.



              First, the varwidth package defines a new column type, but this is not documented in the manual, I found it here: https://texfaq.org/FAQ-varwidcol



              V{4cm}sets the maximum width of a column.



              Second: we need a minimum width. We just can take an empty line of the tabular and fill it with empty spaces of the needed minimum width. To hide this line, I inserted \[-1em], which you need to adapt in your use case. I suggest to put it as first line of the tabular, followed by the head of the tabular, not the other way round.



              Hopefully it works in your use case!



              pic of tabular






              share|improve this answer
























              • Thanks for your effort. You seem to be answering a slightly different question though. Can you elaborate on what you mean by "to do it properly"? How is ruining out of the margins a problem related to setting a minimum width? Doesn't this also happen with a plain begin{tabular}{cccc}-table?

                – sheß
                13 hours ago











              • @sheß Yes, any column of the types c or l or r can become much to broad. So I prefer the p or b or m column type!

                – Keks Dose
                13 hours ago











              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%2f402414%2fspecifying-minimal-not-fixed-width-in-tabular%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              6














              See ADDENDUM and BONUS



              First, the original approach.



              Here is a newcolumntype solution, except that, for a reason that I should know but I don't, it won't work in the last column of the tabular. I'm sure David C. could tell me off the cuff why.



              So I've provided C{}, L{}, and R{} column types for specifying a minimum width, and an Q column type to use for a phantom, to get around the deficiency I initially cited.



              documentclass{article}
              usepackage{tabularx,stackengine}
              newcolumntype{L}[1]{>{minwd l{#1}}l<{endminwd}}
              newcolumntype{C}[1]{>{minwd c{#1}}c<{endminwd}}
              newcolumntype{R}[1]{>{minwd r{#1}}r<{endminwd}}
              defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
              newcolumntype{Q}{@{}c@{}}
              begin{document}
              begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|l|}
              a & a& b& c\
              aaaaaaaaaaaaaaaaa& aa& bb& cc\
              end{tabular}
              bigskip


              begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|Q}
              a & a& b& c&\
              aaaaaaaaaaaaaaaaa& aa& bb& cc&\
              end{tabular}
              end{document}


              enter image description here





              ADDENDUM



              Apparently the way to overcome the deficiency I noted in my original solution is to use collectcell:



              documentclass{article}
              usepackage{tabularx,stackengine,collcell}
              letendminwdrelax
              newcolumntype{L}[1]{>{collectcellxminwd l{#1}}l<{endminwdendcollectcell}}
              newcolumntype{C}[1]{>{collectcellxminwd c{#1}}c<{endminwdendcollectcell}}
              newcolumntype{R}[1]{>{collectcellxminwd r{#1}}r<{endminwdendcollectcell}}
              defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
              newcommandxminwd[1]{minwd#1}
              begin{document}
              begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|}
              a & a& b& c\
              aaaaaaaaaaaaaaaaa& aa& bb& cc\
              end{tabular}
              end{document}


              enter image description here



              And just for fun, if you set the vertical measure of the rule to something nonzero, say 1pt, you can see how the rule comes into play:



              enter image description here





              BONUS



              I realized the technique could be used for creating a D column for aligning a specified number of trailing decimal places. EDITED to handle decimal free inputs.



              documentclass{article}
              usepackage{tabularx,stackengine,collcell}
              letendecmrelax
              newcolumntype{D}[1]{>{collectcellDecm l{#1}}r<{..endDecmendcollectcell}}
              defdecm#1#2#3.#4.#5endDecm{#3.stackengine{0pt}{#4}{rule{#2wd0}{0pt}}{O}{#1}{F}{F}{L}}
              newcommandDecm[1]{setbox0=hbox{0}decm#1}
              begin{document}
              begin{tabular}{|D{3}|D{2}|D{4}|}
              10.345 & 410.34 & 1310.34\
              10 & 11 & 12.\
              210.34 & 1210.3 & 310.3456\
              end{tabular}
              end{document}


              enter image description here






              share|improve this answer






























                6














                See ADDENDUM and BONUS



                First, the original approach.



                Here is a newcolumntype solution, except that, for a reason that I should know but I don't, it won't work in the last column of the tabular. I'm sure David C. could tell me off the cuff why.



                So I've provided C{}, L{}, and R{} column types for specifying a minimum width, and an Q column type to use for a phantom, to get around the deficiency I initially cited.



                documentclass{article}
                usepackage{tabularx,stackengine}
                newcolumntype{L}[1]{>{minwd l{#1}}l<{endminwd}}
                newcolumntype{C}[1]{>{minwd c{#1}}c<{endminwd}}
                newcolumntype{R}[1]{>{minwd r{#1}}r<{endminwd}}
                defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
                newcolumntype{Q}{@{}c@{}}
                begin{document}
                begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|l|}
                a & a& b& c\
                aaaaaaaaaaaaaaaaa& aa& bb& cc\
                end{tabular}
                bigskip


                begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|Q}
                a & a& b& c&\
                aaaaaaaaaaaaaaaaa& aa& bb& cc&\
                end{tabular}
                end{document}


                enter image description here





                ADDENDUM



                Apparently the way to overcome the deficiency I noted in my original solution is to use collectcell:



                documentclass{article}
                usepackage{tabularx,stackengine,collcell}
                letendminwdrelax
                newcolumntype{L}[1]{>{collectcellxminwd l{#1}}l<{endminwdendcollectcell}}
                newcolumntype{C}[1]{>{collectcellxminwd c{#1}}c<{endminwdendcollectcell}}
                newcolumntype{R}[1]{>{collectcellxminwd r{#1}}r<{endminwdendcollectcell}}
                defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
                newcommandxminwd[1]{minwd#1}
                begin{document}
                begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|}
                a & a& b& c\
                aaaaaaaaaaaaaaaaa& aa& bb& cc\
                end{tabular}
                end{document}


                enter image description here



                And just for fun, if you set the vertical measure of the rule to something nonzero, say 1pt, you can see how the rule comes into play:



                enter image description here





                BONUS



                I realized the technique could be used for creating a D column for aligning a specified number of trailing decimal places. EDITED to handle decimal free inputs.



                documentclass{article}
                usepackage{tabularx,stackengine,collcell}
                letendecmrelax
                newcolumntype{D}[1]{>{collectcellDecm l{#1}}r<{..endDecmendcollectcell}}
                defdecm#1#2#3.#4.#5endDecm{#3.stackengine{0pt}{#4}{rule{#2wd0}{0pt}}{O}{#1}{F}{F}{L}}
                newcommandDecm[1]{setbox0=hbox{0}decm#1}
                begin{document}
                begin{tabular}{|D{3}|D{2}|D{4}|}
                10.345 & 410.34 & 1310.34\
                10 & 11 & 12.\
                210.34 & 1210.3 & 310.3456\
                end{tabular}
                end{document}


                enter image description here






                share|improve this answer




























                  6












                  6








                  6







                  See ADDENDUM and BONUS



                  First, the original approach.



                  Here is a newcolumntype solution, except that, for a reason that I should know but I don't, it won't work in the last column of the tabular. I'm sure David C. could tell me off the cuff why.



                  So I've provided C{}, L{}, and R{} column types for specifying a minimum width, and an Q column type to use for a phantom, to get around the deficiency I initially cited.



                  documentclass{article}
                  usepackage{tabularx,stackengine}
                  newcolumntype{L}[1]{>{minwd l{#1}}l<{endminwd}}
                  newcolumntype{C}[1]{>{minwd c{#1}}c<{endminwd}}
                  newcolumntype{R}[1]{>{minwd r{#1}}r<{endminwd}}
                  defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
                  newcolumntype{Q}{@{}c@{}}
                  begin{document}
                  begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|l|}
                  a & a& b& c\
                  aaaaaaaaaaaaaaaaa& aa& bb& cc\
                  end{tabular}
                  bigskip


                  begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|Q}
                  a & a& b& c&\
                  aaaaaaaaaaaaaaaaa& aa& bb& cc&\
                  end{tabular}
                  end{document}


                  enter image description here





                  ADDENDUM



                  Apparently the way to overcome the deficiency I noted in my original solution is to use collectcell:



                  documentclass{article}
                  usepackage{tabularx,stackengine,collcell}
                  letendminwdrelax
                  newcolumntype{L}[1]{>{collectcellxminwd l{#1}}l<{endminwdendcollectcell}}
                  newcolumntype{C}[1]{>{collectcellxminwd c{#1}}c<{endminwdendcollectcell}}
                  newcolumntype{R}[1]{>{collectcellxminwd r{#1}}r<{endminwdendcollectcell}}
                  defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
                  newcommandxminwd[1]{minwd#1}
                  begin{document}
                  begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|}
                  a & a& b& c\
                  aaaaaaaaaaaaaaaaa& aa& bb& cc\
                  end{tabular}
                  end{document}


                  enter image description here



                  And just for fun, if you set the vertical measure of the rule to something nonzero, say 1pt, you can see how the rule comes into play:



                  enter image description here





                  BONUS



                  I realized the technique could be used for creating a D column for aligning a specified number of trailing decimal places. EDITED to handle decimal free inputs.



                  documentclass{article}
                  usepackage{tabularx,stackengine,collcell}
                  letendecmrelax
                  newcolumntype{D}[1]{>{collectcellDecm l{#1}}r<{..endDecmendcollectcell}}
                  defdecm#1#2#3.#4.#5endDecm{#3.stackengine{0pt}{#4}{rule{#2wd0}{0pt}}{O}{#1}{F}{F}{L}}
                  newcommandDecm[1]{setbox0=hbox{0}decm#1}
                  begin{document}
                  begin{tabular}{|D{3}|D{2}|D{4}|}
                  10.345 & 410.34 & 1310.34\
                  10 & 11 & 12.\
                  210.34 & 1210.3 & 310.3456\
                  end{tabular}
                  end{document}


                  enter image description here






                  share|improve this answer















                  See ADDENDUM and BONUS



                  First, the original approach.



                  Here is a newcolumntype solution, except that, for a reason that I should know but I don't, it won't work in the last column of the tabular. I'm sure David C. could tell me off the cuff why.



                  So I've provided C{}, L{}, and R{} column types for specifying a minimum width, and an Q column type to use for a phantom, to get around the deficiency I initially cited.



                  documentclass{article}
                  usepackage{tabularx,stackengine}
                  newcolumntype{L}[1]{>{minwd l{#1}}l<{endminwd}}
                  newcolumntype{C}[1]{>{minwd c{#1}}c<{endminwd}}
                  newcolumntype{R}[1]{>{minwd r{#1}}r<{endminwd}}
                  defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
                  newcolumntype{Q}{@{}c@{}}
                  begin{document}
                  begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|l|}
                  a & a& b& c\
                  aaaaaaaaaaaaaaaaa& aa& bb& cc\
                  end{tabular}
                  bigskip


                  begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|Q}
                  a & a& b& c&\
                  aaaaaaaaaaaaaaaaa& aa& bb& cc&\
                  end{tabular}
                  end{document}


                  enter image description here





                  ADDENDUM



                  Apparently the way to overcome the deficiency I noted in my original solution is to use collectcell:



                  documentclass{article}
                  usepackage{tabularx,stackengine,collcell}
                  letendminwdrelax
                  newcolumntype{L}[1]{>{collectcellxminwd l{#1}}l<{endminwdendcollectcell}}
                  newcolumntype{C}[1]{>{collectcellxminwd c{#1}}c<{endminwdendcollectcell}}
                  newcolumntype{R}[1]{>{collectcellxminwd r{#1}}r<{endminwdendcollectcell}}
                  defminwd#1#2#3endminwd{stackengine{0pt}{#3}{rule{#2}{0pt}}{O}{#1}{F}{F}{L}}
                  newcommandxminwd[1]{minwd#1}
                  begin{document}
                  begin{tabular}{|C{1.2cm}|C{1.2cm}|R{2cm}|L{1.5cm}|}
                  a & a& b& c\
                  aaaaaaaaaaaaaaaaa& aa& bb& cc\
                  end{tabular}
                  end{document}


                  enter image description here



                  And just for fun, if you set the vertical measure of the rule to something nonzero, say 1pt, you can see how the rule comes into play:



                  enter image description here





                  BONUS



                  I realized the technique could be used for creating a D column for aligning a specified number of trailing decimal places. EDITED to handle decimal free inputs.



                  documentclass{article}
                  usepackage{tabularx,stackengine,collcell}
                  letendecmrelax
                  newcolumntype{D}[1]{>{collectcellDecm l{#1}}r<{..endDecmendcollectcell}}
                  defdecm#1#2#3.#4.#5endDecm{#3.stackengine{0pt}{#4}{rule{#2wd0}{0pt}}{O}{#1}{F}{F}{L}}
                  newcommandDecm[1]{setbox0=hbox{0}decm#1}
                  begin{document}
                  begin{tabular}{|D{3}|D{2}|D{4}|}
                  10.345 & 410.34 & 1310.34\
                  10 & 11 & 12.\
                  210.34 & 1210.3 & 310.3456\
                  end{tabular}
                  end{document}


                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 14 hours ago

























                  answered 19 hours ago









                  Steven B. SegletesSteven B. Segletes

                  157k9203411




                  157k9203411























                      11














                      This could be done by placing a row of 0pt rules with a negative row separator (for proper vertical alignment).



                      enter image description here



                      In the example, columns 1 and 2 have minimum width 2cm, while columns 3 and 4 have minimum width 1cm.



                      documentclass{article}

                      begin{document}
                      [
                      begin{tabular}{cccc}
                      rule{2cm}{0pt}&rule{2cm}{0pt}&rule{1cm}{0pt}&rule{1cm}{0pt}\[-arraystretchnormalbaselineskip]]
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]
                      end{document}


                      Update:
                      By placing the rule in a macro, you can adjust the fixed minimum in the document body similarly to a column type.



                      enter image description here



                      Here is the code:



                      documentclass{article}

                      newcommand{fixedmin}[1]{rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}\[-arraystretchnormalbaselineskip]}

                      begin{document}

                      noindent Here is a table with fixed minimum width 2 cm.
                      [
                      begin{tabular}{cccc}fixedmin{2cm}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      noindent Here is a table with fixed minimum width 1 cm.
                      [
                      begin{tabular}{cccc}fixedmin{1cm}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      noindent Here is a table with no fixed minimum width.
                      [
                      begin{tabular}{cccc}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      end{document}





                      share|improve this answer





















                      • 2





                        Great. Is there an easy way to make this a column type?

                        – sheß
                        Nov 22 '17 at 7:22











                      • Nice update. I still hope though that someone will find a way to make this a columntype

                        – sheß
                        20 hours ago











                      • That's a nice low-tech solution.

                        – Circumscribe
                        16 hours ago
















                      11














                      This could be done by placing a row of 0pt rules with a negative row separator (for proper vertical alignment).



                      enter image description here



                      In the example, columns 1 and 2 have minimum width 2cm, while columns 3 and 4 have minimum width 1cm.



                      documentclass{article}

                      begin{document}
                      [
                      begin{tabular}{cccc}
                      rule{2cm}{0pt}&rule{2cm}{0pt}&rule{1cm}{0pt}&rule{1cm}{0pt}\[-arraystretchnormalbaselineskip]]
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]
                      end{document}


                      Update:
                      By placing the rule in a macro, you can adjust the fixed minimum in the document body similarly to a column type.



                      enter image description here



                      Here is the code:



                      documentclass{article}

                      newcommand{fixedmin}[1]{rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}\[-arraystretchnormalbaselineskip]}

                      begin{document}

                      noindent Here is a table with fixed minimum width 2 cm.
                      [
                      begin{tabular}{cccc}fixedmin{2cm}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      noindent Here is a table with fixed minimum width 1 cm.
                      [
                      begin{tabular}{cccc}fixedmin{1cm}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      noindent Here is a table with no fixed minimum width.
                      [
                      begin{tabular}{cccc}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      end{document}





                      share|improve this answer





















                      • 2





                        Great. Is there an easy way to make this a column type?

                        – sheß
                        Nov 22 '17 at 7:22











                      • Nice update. I still hope though that someone will find a way to make this a columntype

                        – sheß
                        20 hours ago











                      • That's a nice low-tech solution.

                        – Circumscribe
                        16 hours ago














                      11












                      11








                      11







                      This could be done by placing a row of 0pt rules with a negative row separator (for proper vertical alignment).



                      enter image description here



                      In the example, columns 1 and 2 have minimum width 2cm, while columns 3 and 4 have minimum width 1cm.



                      documentclass{article}

                      begin{document}
                      [
                      begin{tabular}{cccc}
                      rule{2cm}{0pt}&rule{2cm}{0pt}&rule{1cm}{0pt}&rule{1cm}{0pt}\[-arraystretchnormalbaselineskip]]
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]
                      end{document}


                      Update:
                      By placing the rule in a macro, you can adjust the fixed minimum in the document body similarly to a column type.



                      enter image description here



                      Here is the code:



                      documentclass{article}

                      newcommand{fixedmin}[1]{rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}\[-arraystretchnormalbaselineskip]}

                      begin{document}

                      noindent Here is a table with fixed minimum width 2 cm.
                      [
                      begin{tabular}{cccc}fixedmin{2cm}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      noindent Here is a table with fixed minimum width 1 cm.
                      [
                      begin{tabular}{cccc}fixedmin{1cm}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      noindent Here is a table with no fixed minimum width.
                      [
                      begin{tabular}{cccc}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      end{document}





                      share|improve this answer















                      This could be done by placing a row of 0pt rules with a negative row separator (for proper vertical alignment).



                      enter image description here



                      In the example, columns 1 and 2 have minimum width 2cm, while columns 3 and 4 have minimum width 1cm.



                      documentclass{article}

                      begin{document}
                      [
                      begin{tabular}{cccc}
                      rule{2cm}{0pt}&rule{2cm}{0pt}&rule{1cm}{0pt}&rule{1cm}{0pt}\[-arraystretchnormalbaselineskip]]
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]
                      end{document}


                      Update:
                      By placing the rule in a macro, you can adjust the fixed minimum in the document body similarly to a column type.



                      enter image description here



                      Here is the code:



                      documentclass{article}

                      newcommand{fixedmin}[1]{rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}&rule{#1}{0pt}\[-arraystretchnormalbaselineskip]}

                      begin{document}

                      noindent Here is a table with fixed minimum width 2 cm.
                      [
                      begin{tabular}{cccc}fixedmin{2cm}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      noindent Here is a table with fixed minimum width 1 cm.
                      [
                      begin{tabular}{cccc}fixedmin{1cm}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      noindent Here is a table with no fixed minimum width.
                      [
                      begin{tabular}{cccc}
                      Longer entry here&2&3&4\
                      5&6&Longer entry here&8
                      end{tabular}
                      ]

                      end{document}






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 16 hours ago

























                      answered Nov 21 '17 at 17:59









                      Sandy GSandy G

                      2,7971322




                      2,7971322








                      • 2





                        Great. Is there an easy way to make this a column type?

                        – sheß
                        Nov 22 '17 at 7:22











                      • Nice update. I still hope though that someone will find a way to make this a columntype

                        – sheß
                        20 hours ago











                      • That's a nice low-tech solution.

                        – Circumscribe
                        16 hours ago














                      • 2





                        Great. Is there an easy way to make this a column type?

                        – sheß
                        Nov 22 '17 at 7:22











                      • Nice update. I still hope though that someone will find a way to make this a columntype

                        – sheß
                        20 hours ago











                      • That's a nice low-tech solution.

                        – Circumscribe
                        16 hours ago








                      2




                      2





                      Great. Is there an easy way to make this a column type?

                      – sheß
                      Nov 22 '17 at 7:22





                      Great. Is there an easy way to make this a column type?

                      – sheß
                      Nov 22 '17 at 7:22













                      Nice update. I still hope though that someone will find a way to make this a columntype

                      – sheß
                      20 hours ago





                      Nice update. I still hope though that someone will find a way to make this a columntype

                      – sheß
                      20 hours ago













                      That's a nice low-tech solution.

                      – Circumscribe
                      16 hours ago





                      That's a nice low-tech solution.

                      – Circumscribe
                      16 hours ago











                      7














                      Here's a way to do it using the collcell package. The idea is to measure the content of the cell and then add rules to make up the deficit where appropriate. I've made versions for c, r and l columns. The vertical lines are just there to show the fixed width columns.



                      documentclass{article}
                      usepackage{array,calc,collcell}
                      newlength{fwlen}
                      newcolumntype{C}[1]{>{setlength{fwlen}{#1}collectcellfixedCwidth}c<{endcollectcell}}
                      newcolumntype{R}[1]{>{setlength{fwlen}{#1}collectcellfixedRwidth}r<{endcollectcell}}
                      newcolumntype{L}[1]{>{setlength{fwlen}{#1}collectcellfixedLwidth}l<{endcollectcell}}
                      makeatletter
                      newcommand{fixedCwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{(fwlen-@tempdima)/2}rule{@tempdimb}{0pt}#1rule{@tempdimb}{0pt}fi}
                      newcommand{fixedLwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}#1rule{@tempdimb}{0pt}fi}
                      newcommand{fixedRwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}rule{@tempdimb}{0pt}#1fi}
                      makeatother
                      begin{document}


                      begin{tabular}{|C{1cm}|L{1cm}|R{1cm}|C{1cm}|C{1cm}|}
                      123 & 123 & 123 & 123 & This is a wider column\
                      5 & 6 & 6 & 8 & 8
                      end{tabular}

                      end{document}


                      output of cod






                      share|improve this answer




























                        7














                        Here's a way to do it using the collcell package. The idea is to measure the content of the cell and then add rules to make up the deficit where appropriate. I've made versions for c, r and l columns. The vertical lines are just there to show the fixed width columns.



                        documentclass{article}
                        usepackage{array,calc,collcell}
                        newlength{fwlen}
                        newcolumntype{C}[1]{>{setlength{fwlen}{#1}collectcellfixedCwidth}c<{endcollectcell}}
                        newcolumntype{R}[1]{>{setlength{fwlen}{#1}collectcellfixedRwidth}r<{endcollectcell}}
                        newcolumntype{L}[1]{>{setlength{fwlen}{#1}collectcellfixedLwidth}l<{endcollectcell}}
                        makeatletter
                        newcommand{fixedCwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{(fwlen-@tempdima)/2}rule{@tempdimb}{0pt}#1rule{@tempdimb}{0pt}fi}
                        newcommand{fixedLwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}#1rule{@tempdimb}{0pt}fi}
                        newcommand{fixedRwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}rule{@tempdimb}{0pt}#1fi}
                        makeatother
                        begin{document}


                        begin{tabular}{|C{1cm}|L{1cm}|R{1cm}|C{1cm}|C{1cm}|}
                        123 & 123 & 123 & 123 & This is a wider column\
                        5 & 6 & 6 & 8 & 8
                        end{tabular}

                        end{document}


                        output of cod






                        share|improve this answer


























                          7












                          7








                          7







                          Here's a way to do it using the collcell package. The idea is to measure the content of the cell and then add rules to make up the deficit where appropriate. I've made versions for c, r and l columns. The vertical lines are just there to show the fixed width columns.



                          documentclass{article}
                          usepackage{array,calc,collcell}
                          newlength{fwlen}
                          newcolumntype{C}[1]{>{setlength{fwlen}{#1}collectcellfixedCwidth}c<{endcollectcell}}
                          newcolumntype{R}[1]{>{setlength{fwlen}{#1}collectcellfixedRwidth}r<{endcollectcell}}
                          newcolumntype{L}[1]{>{setlength{fwlen}{#1}collectcellfixedLwidth}l<{endcollectcell}}
                          makeatletter
                          newcommand{fixedCwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{(fwlen-@tempdima)/2}rule{@tempdimb}{0pt}#1rule{@tempdimb}{0pt}fi}
                          newcommand{fixedLwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}#1rule{@tempdimb}{0pt}fi}
                          newcommand{fixedRwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}rule{@tempdimb}{0pt}#1fi}
                          makeatother
                          begin{document}


                          begin{tabular}{|C{1cm}|L{1cm}|R{1cm}|C{1cm}|C{1cm}|}
                          123 & 123 & 123 & 123 & This is a wider column\
                          5 & 6 & 6 & 8 & 8
                          end{tabular}

                          end{document}


                          output of cod






                          share|improve this answer













                          Here's a way to do it using the collcell package. The idea is to measure the content of the cell and then add rules to make up the deficit where appropriate. I've made versions for c, r and l columns. The vertical lines are just there to show the fixed width columns.



                          documentclass{article}
                          usepackage{array,calc,collcell}
                          newlength{fwlen}
                          newcolumntype{C}[1]{>{setlength{fwlen}{#1}collectcellfixedCwidth}c<{endcollectcell}}
                          newcolumntype{R}[1]{>{setlength{fwlen}{#1}collectcellfixedRwidth}r<{endcollectcell}}
                          newcolumntype{L}[1]{>{setlength{fwlen}{#1}collectcellfixedLwidth}l<{endcollectcell}}
                          makeatletter
                          newcommand{fixedCwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{(fwlen-@tempdima)/2}rule{@tempdimb}{0pt}#1rule{@tempdimb}{0pt}fi}
                          newcommand{fixedLwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}#1rule{@tempdimb}{0pt}fi}
                          newcommand{fixedRwidth}[1]{setlength{@tempdima}{widthof{#1}}ifdim@tempdima>fwlen #1elsesetlength{@tempdimb}{fwlen-@tempdima}rule{@tempdimb}{0pt}#1fi}
                          makeatother
                          begin{document}


                          begin{tabular}{|C{1cm}|L{1cm}|R{1cm}|C{1cm}|C{1cm}|}
                          123 & 123 & 123 & 123 & This is a wider column\
                          5 & 6 & 6 & 8 & 8
                          end{tabular}

                          end{document}


                          output of cod







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 19 hours ago









                          Alan MunnAlan Munn

                          161k28431706




                          161k28431706























                              2














                              To do it properly, you need a minimum width and a maximum width of each column. You required the minimum width in your question. I'd say, it is better to have a maximum width, because otherwise your tabular might run out of the margin.



                              documentclass{article}
                              usepackage{array}
                              usepackage{varwidth}% varwidth defines a new column type V.

                              begin{document}
                              begin{tabular}{*{4}{V{4cm}}}
                              hspace*{2cm} & hspace*{2cm} & hspace*{1cm} & hspace*{1cm}\[-1em]
                              Longer entry here&2&3&4\
                              5&6&Longer entry here, which gets wrapped finaly&8\
                              end{tabular}
                              end{document}


                              There are to small tricks.



                              First, the varwidth package defines a new column type, but this is not documented in the manual, I found it here: https://texfaq.org/FAQ-varwidcol



                              V{4cm}sets the maximum width of a column.



                              Second: we need a minimum width. We just can take an empty line of the tabular and fill it with empty spaces of the needed minimum width. To hide this line, I inserted \[-1em], which you need to adapt in your use case. I suggest to put it as first line of the tabular, followed by the head of the tabular, not the other way round.



                              Hopefully it works in your use case!



                              pic of tabular






                              share|improve this answer
























                              • Thanks for your effort. You seem to be answering a slightly different question though. Can you elaborate on what you mean by "to do it properly"? How is ruining out of the margins a problem related to setting a minimum width? Doesn't this also happen with a plain begin{tabular}{cccc}-table?

                                – sheß
                                13 hours ago











                              • @sheß Yes, any column of the types c or l or r can become much to broad. So I prefer the p or b or m column type!

                                – Keks Dose
                                13 hours ago
















                              2














                              To do it properly, you need a minimum width and a maximum width of each column. You required the minimum width in your question. I'd say, it is better to have a maximum width, because otherwise your tabular might run out of the margin.



                              documentclass{article}
                              usepackage{array}
                              usepackage{varwidth}% varwidth defines a new column type V.

                              begin{document}
                              begin{tabular}{*{4}{V{4cm}}}
                              hspace*{2cm} & hspace*{2cm} & hspace*{1cm} & hspace*{1cm}\[-1em]
                              Longer entry here&2&3&4\
                              5&6&Longer entry here, which gets wrapped finaly&8\
                              end{tabular}
                              end{document}


                              There are to small tricks.



                              First, the varwidth package defines a new column type, but this is not documented in the manual, I found it here: https://texfaq.org/FAQ-varwidcol



                              V{4cm}sets the maximum width of a column.



                              Second: we need a minimum width. We just can take an empty line of the tabular and fill it with empty spaces of the needed minimum width. To hide this line, I inserted \[-1em], which you need to adapt in your use case. I suggest to put it as first line of the tabular, followed by the head of the tabular, not the other way round.



                              Hopefully it works in your use case!



                              pic of tabular






                              share|improve this answer
























                              • Thanks for your effort. You seem to be answering a slightly different question though. Can you elaborate on what you mean by "to do it properly"? How is ruining out of the margins a problem related to setting a minimum width? Doesn't this also happen with a plain begin{tabular}{cccc}-table?

                                – sheß
                                13 hours ago











                              • @sheß Yes, any column of the types c or l or r can become much to broad. So I prefer the p or b or m column type!

                                – Keks Dose
                                13 hours ago














                              2












                              2








                              2







                              To do it properly, you need a minimum width and a maximum width of each column. You required the minimum width in your question. I'd say, it is better to have a maximum width, because otherwise your tabular might run out of the margin.



                              documentclass{article}
                              usepackage{array}
                              usepackage{varwidth}% varwidth defines a new column type V.

                              begin{document}
                              begin{tabular}{*{4}{V{4cm}}}
                              hspace*{2cm} & hspace*{2cm} & hspace*{1cm} & hspace*{1cm}\[-1em]
                              Longer entry here&2&3&4\
                              5&6&Longer entry here, which gets wrapped finaly&8\
                              end{tabular}
                              end{document}


                              There are to small tricks.



                              First, the varwidth package defines a new column type, but this is not documented in the manual, I found it here: https://texfaq.org/FAQ-varwidcol



                              V{4cm}sets the maximum width of a column.



                              Second: we need a minimum width. We just can take an empty line of the tabular and fill it with empty spaces of the needed minimum width. To hide this line, I inserted \[-1em], which you need to adapt in your use case. I suggest to put it as first line of the tabular, followed by the head of the tabular, not the other way round.



                              Hopefully it works in your use case!



                              pic of tabular






                              share|improve this answer













                              To do it properly, you need a minimum width and a maximum width of each column. You required the minimum width in your question. I'd say, it is better to have a maximum width, because otherwise your tabular might run out of the margin.



                              documentclass{article}
                              usepackage{array}
                              usepackage{varwidth}% varwidth defines a new column type V.

                              begin{document}
                              begin{tabular}{*{4}{V{4cm}}}
                              hspace*{2cm} & hspace*{2cm} & hspace*{1cm} & hspace*{1cm}\[-1em]
                              Longer entry here&2&3&4\
                              5&6&Longer entry here, which gets wrapped finaly&8\
                              end{tabular}
                              end{document}


                              There are to small tricks.



                              First, the varwidth package defines a new column type, but this is not documented in the manual, I found it here: https://texfaq.org/FAQ-varwidcol



                              V{4cm}sets the maximum width of a column.



                              Second: we need a minimum width. We just can take an empty line of the tabular and fill it with empty spaces of the needed minimum width. To hide this line, I inserted \[-1em], which you need to adapt in your use case. I suggest to put it as first line of the tabular, followed by the head of the tabular, not the other way round.



                              Hopefully it works in your use case!



                              pic of tabular







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 15 hours ago









                              Keks DoseKeks Dose

                              21.2k35394




                              21.2k35394













                              • Thanks for your effort. You seem to be answering a slightly different question though. Can you elaborate on what you mean by "to do it properly"? How is ruining out of the margins a problem related to setting a minimum width? Doesn't this also happen with a plain begin{tabular}{cccc}-table?

                                – sheß
                                13 hours ago











                              • @sheß Yes, any column of the types c or l or r can become much to broad. So I prefer the p or b or m column type!

                                – Keks Dose
                                13 hours ago



















                              • Thanks for your effort. You seem to be answering a slightly different question though. Can you elaborate on what you mean by "to do it properly"? How is ruining out of the margins a problem related to setting a minimum width? Doesn't this also happen with a plain begin{tabular}{cccc}-table?

                                – sheß
                                13 hours ago











                              • @sheß Yes, any column of the types c or l or r can become much to broad. So I prefer the p or b or m column type!

                                – Keks Dose
                                13 hours ago

















                              Thanks for your effort. You seem to be answering a slightly different question though. Can you elaborate on what you mean by "to do it properly"? How is ruining out of the margins a problem related to setting a minimum width? Doesn't this also happen with a plain begin{tabular}{cccc}-table?

                              – sheß
                              13 hours ago





                              Thanks for your effort. You seem to be answering a slightly different question though. Can you elaborate on what you mean by "to do it properly"? How is ruining out of the margins a problem related to setting a minimum width? Doesn't this also happen with a plain begin{tabular}{cccc}-table?

                              – sheß
                              13 hours ago













                              @sheß Yes, any column of the types c or l or r can become much to broad. So I prefer the p or b or m column type!

                              – Keks Dose
                              13 hours ago





                              @sheß Yes, any column of the types c or l or r can become much to broad. So I prefer the p or b or m column type!

                              – Keks Dose
                              13 hours ago


















                              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%2f402414%2fspecifying-minimal-not-fixed-width-in-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

                              El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

                              Castillo d'Acher Características Menú de navegación

                              Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...