在表格中的对角线文本旁边添加行

在表格中的对角线文本旁边添加行

我尝试在左侧对角线文本旁边添加“Datum”、“Fahrt Nr”和“Linie”列,但无法实现,因为它总是出现在我的表格上方。有什么想法可以实现吗?

谢谢!

在此处输入图片描述

\documentclass{article}

\usepackage{makecell,threeparttable,caption}
\usepackage[export]{adjustbox}

%% Rotation
\ExplSyntaxOn

\NewDocumentCommand { \rot } { m }
  { 
    \hbox_to_wd:nn { 1 em }
      { 
        \hbox_overlap_right:n 
          { 
            \skip_horizontal:n { \fp_to_dim:n { 7 * cosd (\Angle) } } 
            \rotatebox{\Angle}{#1}
          } 
      } 
  }
\ExplSyntaxOff

\begin{document}

\def\Angle{45}

\begin{threeparttable}

%% Part 1 of 3: the caption

\caption*{Fahrtenprotokoll:}
\label{tab:protokoll}

%% Part 2 of 3: the table
\begin{tabular}{l}
Fahrt Nr: \\
Linie: \\
Datum: \\
\end{tabular}
\begin{tabular}{|c|p{5cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{2.25cm}|}
\multicolumn{1}{c}{KP} &
\multicolumn{1}{c}{Bezeichnung} &
\multicolumn{1}{c}{\rot{Fahrzeit zwischen KP [s]}} &
\multicolumn{1}{c}{\rot{Haltezeit LSA [s]}} &
\multicolumn{1}{c}{\rot{Haltezeit HS [s]}} &
\multicolumn{1}{c}{\rot{Fahrgastwechselzeit [s]}} &
\multicolumn{1}{c}{\rot{Fahrzeit zwischen HS [s]}} &
\multicolumn{1}{c}{Sonstiges} \\ \hline
HS 1       &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 1.1    &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 1.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
HS 2       &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 2.1    &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 2.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
HS 3       &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 3.1    &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 3.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
HS 4       &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 4.1    &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 4.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
\multicolumn{3}{r|}{Gesamt:}  &  &  &  &     \\ \cline{4-7}

\end{tabular}

%% Part 3 of 3: the tablenotes environment
\smallskip
\footnotesize
\begin{tablenotes}[flushleft]
\item[] KP: Knotenpunkt, HS: Haltestelle
\end{tablenotes}

\end{threeparttable}




\end{document}

答案1

问题不太清楚所以......

选项1

\documentclass{article}

\usepackage{makecell,threeparttable,caption}
\usepackage[export]{adjustbox}

%% Rotation
\ExplSyntaxOn

\NewDocumentCommand { \rot } { m }
{ 
    \hbox_to_wd:nn { 1 em }
    { 
        \hbox_overlap_right:n 
        { 
            \skip_horizontal:n { \fp_to_dim:n { 7 * cosd (\Angle) } } 
            \rotatebox{\Angle}{#1}
        } 
    } 
}
\ExplSyntaxOff

\begin{document}
    
    \def\Angle{45}
    
    \begin{threeparttable}
        
        %% Part 1 of 3: the caption
        
        \caption*{Fahrtenprotokoll:}
        \label{tab:protokoll}
        
        \begin{tabular}{|c|p{5cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{2.25cm}|}
%           \cline{1-1}
%           \multicolumn{1}{|l|}{Fahrt Nr:}\\ 
%           \multicolumn{1}{|l|}{Linie: }\\
%           \multicolumn{1}{|l|}{Datum: } \\ 
%           \cline{1-1}
            \multicolumn{1}{c}{\makecell{Fahrt Nr:\\Linie:\\Datum:\\KP}} &
            \multicolumn{1}{c}{Bezeichnung} &
            \multicolumn{1}{c}{\rot{Fahrzeit zwischen KP [s]}} &
            \multicolumn{1}{c}{\rot{Haltezeit LSA [s]}} &
            \multicolumn{1}{c}{\rot{Haltezeit HS [s]}} &
            \multicolumn{1}{c}{\rot{Fahrgastwechselzeit [s]}} &
            \multicolumn{1}{c}{\rot{Fahrzeit zwischen HS [s]}} &
            \multicolumn{1}{c}{Sonstiges} \\ \hline
            HS 1       &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 1.1    &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 1.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
            HS 2       &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 2.1    &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 2.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
            HS 3       &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 3.1    &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 3.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
            HS 4       &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 4.1    &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 4.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
            \multicolumn{3}{r|}{Gesamt:}  &  &  &  &     \\ \cline{4-7}
            
        \end{tabular}
        
        %% Part 3 of 3: the tablenotes environment
        \smallskip
        \footnotesize
        \begin{tablenotes}[flushleft]
            \item[] KP: Knotenpunkt, HS: Haltestelle
        \end{tablenotes}
        
    \end{threeparttable}
    
    
    
    
\end{document}

在此处输入图片描述

选项 2

\documentclass{article}

\usepackage{makecell,threeparttable,caption}
\usepackage[export]{adjustbox}

%% Rotation
\ExplSyntaxOn

\NewDocumentCommand { \rot } { m }
{ 
    \hbox_to_wd:nn { 1 em }
    { 
        \hbox_overlap_right:n 
        { 
            \skip_horizontal:n { \fp_to_dim:n { 7 * cosd (\Angle) } } 
            \rotatebox{\Angle}{#1}
        } 
    } 
}
\ExplSyntaxOff

\begin{document}
    
    \def\Angle{45}
    
    \begin{threeparttable}
        
        %% Part 1 of 3: the caption
        
        \caption*{Fahrtenprotokoll:}
        \label{tab:protokoll}
        
        \begin{tabular}{|c|p{5cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{2.25cm}|}
            \cline{1-1}
            \multicolumn{1}{|l|}{Fahrt Nr:}\\ 
            \multicolumn{1}{|l|}{Linie: }\\
            \multicolumn{1}{|l|}{Datum: } \\ 
            \cline{1-1}
            \multicolumn{1}{c}{KP} &
            \multicolumn{1}{c}{Bezeichnung} &
            \multicolumn{1}{c}{\rot{Fahrzeit zwischen KP [s]}} &
            \multicolumn{1}{c}{\rot{Haltezeit LSA [s]}} &
            \multicolumn{1}{c}{\rot{Haltezeit HS [s]}} &
            \multicolumn{1}{c}{\rot{Fahrgastwechselzeit [s]}} &
            \multicolumn{1}{c}{\rot{Fahrzeit zwischen HS [s]}} &
            \multicolumn{1}{c}{Sonstiges} \\ \hline
            HS 1       &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 1.1    &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 1.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
            HS 2       &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 2.1    &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 2.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
            HS 3       &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 3.1    &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 3.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
            HS 4       &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 4.1    &  &  &  &  &  &  &      \\ \cline{1-4}
            LSA 4.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
            \multicolumn{3}{r|}{Gesamt:}  &  &  &  &     \\ \cline{4-7}
            
        \end{tabular}
        
        %% Part 3 of 3: the tablenotes environment
        \smallskip
        \footnotesize
        \begin{tablenotes}[flushleft]
            \item[] KP: Knotenpunkt, HS: Haltestelle
        \end{tablenotes}
        
    \end{threeparttable}
    
    
    
    
\end{document}

在此处输入图片描述

答案2

@jsbibra 的回答为我指明了正确的方向,并且我使用 \makecell 实现了它。

如果有人遇到类似的问题,这是我的解决方案:

\documentclass{article}

\usepackage{makecell,threeparttable,caption}
\usepackage[export]{adjustbox}

%% Rotation
\ExplSyntaxOn

\NewDocumentCommand { \rot } { m }
  { 
    \hbox_to_wd:nn { 1 em }
      { 
        \hbox_overlap_right:n 
          { 
            \skip_horizontal:n { \fp_to_dim:n { 7 * cosd (\Angle) } } 
            \rotatebox{\Angle}{#1}
          } 
      } 
  }
\ExplSyntaxOff

\begin{document}

\def\Angle{45}

\begin{threeparttable}

%% Part 1 of 3: the caption
\caption*{Fahrtenprotokoll:}
\label{tab:protokoll}

%% Part 2 of 3: the table
\begin{tabular}{|c|p{5cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{0.75cm}|p{2.25cm}|}
\multicolumn{1}{c}{\makecell[bl]{Fahrt Nr:\\Linie:\\Datum:\\ \\ \\ \\ \makecell[bc]{KP}}} &
\multicolumn{1}{c}{\makecell[b]{Bezeichnung}} &
\multicolumn{1}{c}{\makecell[b]{\rot{Fahrzeit zwischen KP [s]}}} &
\multicolumn{1}{c}{\makecell[b]{\rot{Haltezeit LSA [s]}}} &
\multicolumn{1}{c}{\makecell[b]{\rot{Haltezeit HS [s]}}} &
\multicolumn{1}{c}{\makecell[b]{\rot{Fahrgastwechselzeit [s]}}} &
\multicolumn{1}{c}{\makecell[b]{\rot{Fahrzeit zwischen HS [s]}}} &
\multicolumn{1}{c}{\makecell[b]{Sonstiges}} \\ \hline
HS 1       &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 1.1    &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 1.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
HS 2       &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 2.1    &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 2.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
HS 3       &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 3.1    &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 3.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
HS 4       &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 4.1    &  &  &  &  &  &  &      \\ \cline{1-4}
LSA 4.2    &  &  &  &  &  &  &      \\ \Xhline{1.5pt}
\multicolumn{3}{r|}{Gesamt:}  &  &  &  &     \\ \cline{4-7}
\end{tabular}

%% Part 3 of 3: the tablenotes environment
\smallskip
\footnotesize
\begin{tablenotes}[flushleft]
\item[] KP: Knotenpunkt, HS: Haltestelle
\end{tablenotes}

\end{threeparttable}


\end{document}

在此处输入图片描述

相关内容