Home computickets Creating a table with a different number of cells in lines in...

Creating a table with a different number of cells in lines in latex

Author

Date

Category

How to make such a table in Latex ?

The bottom line is that the first and last columns should be aligned in width.
Cells in the middle should look like this: in the first two lines between the first and second column there are five identical in the width of the cells, in the third line – four, and in the last two lines – also five.

Photo expresses table structure.

Table for calculating the value of the value with an error based on the results of several measurements.


Answer 1, Authority 100%

If the author of the question attached his attempt to make such a table, then I could use data from there (so that it is not to spend time to enter formulas). But since the example was not, I will give tables with minimal content.

To create such a table, you can make the nested table and use the \ Multicolumn command. The problem will be unfolding, which inserts around the cells – in the nested table they will differ from the external. Therefore, the easiest way to get rid of all these folds (by the @ {} command in the preamble of each table). To set the cells it will be more convenient to use one of the columns specifiers from the Array : p , m or b – they allow Hands set the required column width (this applies to the first and last, which should be wider than others). Next, you can use the same type for all internal columns, but then you need the size to select accurately that the vertical lines coincide. Either you can use the column specifier x from the Tabularx package and the environment for the TABULARX tables, which allows you to set the width of the entire table. Next, a couple of examples.

First option: Used the usual environment Tabular and manual selection of column widths.

\ documentclass [11pt] {article}
\ UsePackage [UTF8] {inputenc}
\ Usepackage {Array}
\ NewColumntype {C} [1] {& gt; {\ CENTERING \ ARRAYBACKSLASH} ​​P {# 1}}
\ Begin {Document}
\ Centering
\ Begin {Tabular} {| @ {} C {20mm} @ {} | * {5} {@ {} C {8mm} @ {} |} @ {} C {20mm} @ {} | }
  \ hline
  A & AMP; B & AMP; C & AMP; D & AMP; E & amp; F & AMP; G \\ \ Hline
  A & AMP; B & AMP; C & AMP; D & AMP; E & amp; F & AMP; G \\ \ Hline
  Start & Amp;
      \ Multicolumn {5} {@ {} l @ {}} {
        \ Begin {Tabular} {* {4} {@ {} C {10.1mm} @ {} |}}
          1 & amp; 2 & amp; 3 & amp; 4% \\ \ hline 1 & amp; 2 & amp; 3 & amp; 4 \\
        \ End {Tabular}}
  & amp; END \\ \ Hline
  A & AMP; B & AMP; C & AMP; D & AMP; E & amp; F & AMP; G \\ \ Hline
  A & AMP; B & AMP; C & AMP; D & AMP; E & amp; F & AMP; G \\ \ Hline
\ End {Tabular}
\ End {Document}

The result looks like this:

The second option, with automatic calculation of the width of the internal columns and the environment TabularX it seems to me more comfortable; Here you only need to specify the width of the entire widths of the first and last column (for nested and external tables, these values ​​must, of course, coincide):

\ documentclass [11pt] {article}
\ UsePackage [UTF8] {inputenc}
\ Usepackage {Array}
\ UsePackage {TabularX}
\ NewColumntype {C} [1] {& gt; {\ CENTERING \ ARRAYBACKSLASH} ​​P {# 1}}
\ Begin {Document}
\ Centering
\ Begin {TabularX} {100mm} {| @ {} C {15mm} @ {} | * {5} {@ {} {{@ {} & gt; {\ centering \ arraybackslash} x @ {} |} @ {} C {15mm} @ {} | }
  \ hline
  A & AMP; B & AMP; C & AMP; D & AMP; E & amp; F & AMP; G \\ \ Hline
  A & AMP; B & AMP; C & AMP; D & AMP; E & amp; F & AMP; G \\ \ Hline
  \ Multicolumn {7} {@ {} l @ {}} {
    \ Begin {TabularX} {100mm} {| @ {} C {15mm} @ {} |
        @ {} * {4} {@ {} & gt; {\ centering \ arraybackslash} x @ {} |}
        @ {} C {15mm} @ {} |} 
Start & Amp; 1 & amp; 2 & amp; 3 & amp; 4 & amp; STOP% \\ \ Hline Start & Amp; 1 & amp; 2 & amp; 3 & amp; 4 & amp; Stop \\
  \ End {TabularX}} \\ \ Hline
  A & AMP; B & AMP; C & AMP; D & AMP; E & amp; F & AMP; G \\ \ Hline
  A & AMP; B & AMP; C & AMP; D & AMP; E & amp; F & AMP; G \\ \ Hline
\ End {TabularX}
\ End {Document}

, respectively, the result for this option:

In both cases, the C defined by me was used for the columns of the fixed width in the preamble, and I did not override the column, and simply explicitly added to the preamble of the table & GT; {\ CENTERING \ ARRAYBACKSLASH} ​​– it simply should align the contents of the cell in the center.

Also, in both cases, I left the second line commented for the subfed table – you can unassign and see how the tables will look like in this case.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions