1

I am trying to make the follwing longtable shown in the picture below enter image description here

I have however two questions ?

  1. How can I center the items of the 1st,2nd,3rd and 5th column ( Rotation, Material etc..)
  2. How can I set the width of the 3 column (a lot of white space)

I would be very thankful if anybody could give me a hint here.

Here is the code I used

    \usepackage[ngerman]{babel} 
    
    %Tabellen
    
    \usepackage{longtable}                                      % Paket für Tabellen, die über mehrere Seiten gehen
    
    \usepackage{multicol} 
    
    \usepackage{array}  
    
    \usepackage{caption}  
    
    \begin{document}
    
    \centering
    
    
    \begin{longtable}{|c|c|c|c|c|c|c|}
    
    \caption[Darstellung der verschiedenen Parameter beider Versuchsgeneratoren]{Darstellung der verschiedenen Parameter beider Versuchsgeneratoren} \label{tab:Darstellung der verschiedenen Parameter beider Versuchsgeneratoren} \\
    
    \hline
    
    \multicolumn{1}{|c|}{\textbf{-}} & 
    
    \multicolumn{1}{c|}{\textbf{-}} & 
    
    \multicolumn{2}{c|}{\textbf{Druckplatte}} &
    
    \multicolumn{2}{c|}{\textbf{Pressfinger}} & 
    
    \multicolumn{1}{c|}{\textbf{Polschuh}}\\
    
    \hline 
    
    \endfirsthead
    
    
    \multicolumn{3}{c}%
    
    {{\bfseries \tablename\ \thetable{} -- Fortsetzung von vorheriger Seite}} \\
    
    \hline 
    
    \multicolumn{1}{|c|}{\textbf{-}} & 
    
    \multicolumn{1}{c|}{\textbf{-}} & 
    
    \multicolumn{2}{c|}{\textbf{Druckplatte}} &
    
    \multicolumn{2}{c|}{\textbf{Pressfinger}} & 
    
    \multicolumn{1}{c|}{\textbf{Polschuh}}\\
    
    \hline
    
    \endhead
    
    \hline 
    
    \multicolumn{3}{|r|}{{Fortsetzung auf der nächsten Seite}} \\ \hline
    
    \endfoot
    
    \hline 
    
    \hline
    
    \endlastfoot
    
    \textbf{Nr.} &  Luftspaltsflussdichte  &  Material & Axiale &  Rotation in ° & Radiale  & Axiale \\
      
     & & & Position & & Position & Position \\
    
      \hline
    
      & & & & & & \\
    
      \hline
    
    & & & & & & \\
    
      \hline
    
     & & & & & & \\
    
      \hline
    
    &  & & & & & \\
    
      \hline
    
    & & & & & &\\
    
      \hline
    
     & & & & & & \\
    
      \hline
    
    & &  & & & & \\
    
      \hline
    
    & &  & & & & \\
    
      \hline
    
     & & & & & & \\
    
      \hline
    
    & &  & & & & \\
    
      \hline
    
     & &  & & & & \\
    
      \hline
    
    & & & & & & \\
    
      \hline
    
     & & & & & & \\
    
      \hline
    
     &  & & & & &\\
    
      \hline
    
     & & & & & & \\
    
      \hline
    
     &  &  & & & & \\
    
      \hline
    
    &  &  & & & & \\
    
      \hline
    
     &  &  & & & &  \\
    
      \hline
     
      & &  & & & & \\
     
      \hline
     &  &   & & & & \\
    
    \end{longtable}
    
    \end{document}
2
  • Hi there! I'm not successful in tables , but I know about the fixed size of a table's columns which can be described with this code: \begin{tabular}{|P{3cm}|P{2cm}|P{2cm}|P{2cm}|P{2cm}|P{2cm}|} \hline My first column & Data & Data & Data & Data & Data \\ \hline & & & & &\\ \hline \end{tabular} and you can you this code inside the \begin{table} \end{table} environment hope this can help in any way Mar 17 at 12:35
  • 1
    I think that will work as well , I haven't thought about it. I don't use the P declaration mostly because it influences the spacing in the cell when long sentences are used inside a cell. Mar 18 at 9:13

1 Answer 1

2

Like this:

enter image description here

With tabularray package is simple. All columns except firs has equal width and contents in them are centered.

\documentclass{article}
\usepackage{geometry}
\usepackage[ngerman]{babel}
\usepackage{tabularray} 
\usepackage{caption}

\begin{document}
    \begin{longtblr}[
caption = {Darstellung der verschiedenen Parameter beider Versuchsgeneratoren},
  entry = {Darstellung der verschiedenen Parameter beider Versuchsgeneratoren},
  label = {tab:Darstellung der verschiedenen Parameter beider Versuchsgeneratoren}
                    ]{hlines, vlines,
                     colspec={c *{6}{X[c]}},
                     colsep=4pt,
                     row{1-2} = {font=\small\bfseries, c, b},
                     rowhead=2
                     }
--  & -- & \SetCell[c=2]{c}  Druckplatte
            &   & \SetCell[c=2]{c}  Pressfinger
                    &   &   Polschuh                    \\
Nr. &  {Luftspalt-\\ sflussdichte}  
        &  Material 
            & {Axiale\\ Position}
                & {Rotation\\ in °} 
                    & {Radiale\\ Position}  
                        & {Axiale\\ Position}   \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    &   &   &   &   &   &                       \\
    \end{longtblr}
\end{document}
3
  • thank you very much , this solution works. Mar 18 at 9:14
  • @Zarko good and wise solution. But I didn't get how come the "Polschuh " column appears without \SetCell [] ... I just have similiar table columns and rows merging job and it isn't still done, that's why I'm asking Mar 18 at 10:47
  • 1
    @Programmer1988, I do not understand what is your problem. for column header of the last column you not need \SetCell instruction. Fromation of the first two rows is determined by row{1-2} = {font=\small\bfseries, c, b}, in preamble, which say: text in those rows are boldface, horizontal centered in cells and at bottom aligned. For better answer/help consider to ask a question where explain, what is your problem.
    – Zarko
    Mar 18 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.