多列表格中的文本定位

多列表格中的文本定位

我有一个包含表格的 word 文档。各列的列宽不同。附件在此处。 在此处输入图片描述

我想将单词 table 翻译成 LaTex。LaTeX 中的新表格看起来很糟糕。文本对齐方式很糟糕。此外,我收到 Overleaf 的警告,提示“Overfull” \hbox。我不确定为什么会收到有关表格宽度的警告。新表格在这里。 在此处输入图片描述

\documentclass[a4paper,landscape]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[nottoc]{tocbibind}
\usepackage[margin=24mm,
        bottom= 5mm,%
        footskip=4\baselineskip,
        includefoot,
        % showframe
        ]{geometry}
\usepackage{tikz}
\usetikzlibrary{backgrounds, positioning, scopes}
\tikzset{FOOT/.style = {
every node/.append style = {font=\sffamily\bfseries,
                        text=white,
                        align=center,
                        minimum height=15mm,
                        outer sep=0pt,
                        },
           sx/.style = {xshift=##1mm}
                    }
    }
\usepackage{color,soul}
\usepackage[usestackEOL]{stackengine}
\usepackage{caption}
\usepackage{placeins}
\usepackage{subcaption}
\usepackage{tcolorbox}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{csquotes}
\usepackage[normalem]{ulem}
\usepackage{multirow}
% To add URL of website
\usepackage{url}
% Set line spacing using the following package
\usepackage{setspace}
\usepackage{lastpage}
%% Useful packages
\usepackage{amsmath}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{2pt}

\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\definecolor{darkgoldenrod}{rgb}{0.72, 0.53, 0.04}
\usepackage{cleveref}

\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\usepackage[normalem]{ulem}
\useunder{\uline}{\ul}{}
% \fancyhead{} % clear all header fields
\fancyhead[RO]{Development Action Plan}
\fancyfoot{} % clear all footer fields

%%========================= Footer template ============================
\fancyfoot[O]{% odd pages
\begin{tikzpicture}[FOOT,
remember picture, overlay,
node distance=0pt]
\node (O1) [minimum width=25mm,
        above right=of current page.south west]
        {};
\node (O2) [minimum width=0.5\textwidth, align=left,
        right=of O1]
        { Continuing Professional Development\\
            \footnotesize
          January 2019};
\node (O3) [minimum width=0.5\textwidth,
        align=center,
        right=of O2]
        { LarCoS\\
            \footnotesize
        Membership no. 123456\qquad};
\node (O4) [minimum width=25mm, font=\sffamily\bfseries,
        right=of O3]
        {\thepage~of~\pageref*{LastPage}};
\begin{scope}[on background layer]
\fill[teal] (O1.south west) |- ([sx= 3] O3.north east)
                        -- ([sx=-3] O3.south east)
                         -- cycle;
\fill[black] ([sx=-3] O2.south east) -- ([sx= 3] O2.north east) -|
        (O4.south east) -- cycle;
\path[white, line width=1mm, shorten >=-0.5mm, shorten < =-0.5mm]
        ([sx=-3] O2.south east) edge ([sx=3] O2.north east)
        ([sx=-3] O4.south west) edge ([sx=3] O4.north west);
\end{scope}
\end{tikzpicture}
            } %odd page
%%%%==========================================
%%========================= Footer template ============================
\begin{document}

\begin{table}[tbh]
\begin{tabular}{|C{0.75cm}|C{0.7cm}|L{3cm}|L{3.25cm}|L{3cm}|L{2.7cm}|L{3cm}|L{2.45cm}|L{2.1cm}|}
\hline
\multicolumn{9}{|l|}{\textbf{Job role and responsibilities:}}       \\ \hline
\multicolumn{5}{|c|}{\textbf{Review of learning needs}} & \multicolumn{4}{c|}{\textbf{Development plan}}\\ \hline
\textbf{Date} & \textbf{Ref} & \textbf{\begin{tabular}[c]{@{}l@{}}In what area do \\  I need to improve \\ my  performance?\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}How does this link\\ to other objectives\\  (eg employer, ICE,\\  etc)?\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}What do I need\\  to learn in\\  order to \\ achieve this?\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}What will I do\\  to achieve this?\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}What are the \\ likely resources \\ and support \\ that I will need?\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}How will I\\ evaluate a\\ successful \\ outcome?\end{tabular}} & \textbf{\begin{tabular}[c]{@{}l@{}}What are\\ my \\ deadlines \\for meeting \\this target?\end{tabular}} \\ \hline

Jul 2006 &   RB-DAP-01   &~Understanding structural steel detail drawings and preparing design drawing using AutoCAD~&~Knowledge of load transfer thorough proper detailing and to be represented in drawings  &  Several structural components and their behaviour under loading; for AutoCAD, needed to learn the commands  &  Rigorous study of design drawings and draw the details using AutoCAD  &  Drawings from previous projects and the software AutoCAD and its manuals & I shall be able to prepare structural detailing using AutoCAD & Sep 2006 \\ \hline



              &              &                                                                                                           &                                                                                                                          &                                                                                                             &                                                                                     &                                                                                                                       &                                                                                                      &                                                                                                          \\ \hline



              &              &                                                                                                           &                                                                                                                          &                                                                                                             &                                                                                     &                                                                                                                       &                                                                                                      &                                                                                                          \\ \hline



              &              &                                                                                                           &                                                                                                                          &                                                                                                             &                                                                                     &                                                                                                                       &                                                                                                      &                                                                                                          \\ \hline
\end{tabular}
\end{table}

\end{document}

答案1

像这样?

在此处输入图片描述

(红线表示文本区域)

我将您的 mwe 缩减为仅涉及表格的部分。为此,我添加了三个包:(ragged2e用于表格单元格中文本的更好连字)makecell(用于单元格内容周围的更多垂直空间)和tabularx(用于宽度相等的多行单元格):

\documentclass[a4paper,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage[margin=24mm,
        bottom= 5mm,%
        footskip=4\baselineskip,
        includefoot,
        % showframe
        ]{geometry}
\usepackage{caption}
\usepackage{ragged2e} % <---

\usepackage{array, makecell, multirow, tabularx}  % <---

\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X}
\newcolumntype{C}{>{\Centering  \arraybackslash}X}

\begin{document}

    \begin{table}[htb]
    \setcellgapes{5pt}
    \makegapedcells
    \setlength\tabcolsep{4pt}
\begin{tabularx}{\linewidth}{|c|c|*{7}{L|}}
\hline
\multicolumn{9}{|l|}{\textbf{Job role and responsibilities:}}   \\
    \hline
\multicolumn{5}{|c|}{\textbf{Review of learning needs}}
    & \multicolumn{4}{c|}{\textbf{Development plan}}            \\
    \hline
\textbf{Date}
    & \textbf{Ref} & \textbf{In what area do  I need to improve my  performance?}
        & \textbf{How does this link to other objectives  (eg employer, ICE,  etc)?}
            & \textbf{What do I need to learn in order to achieve this?}
                & \textbf{What will I do to achieve this?}
                    & \textbf{What are the likely resources and support that I will need?}
                        & \textbf{How will I evaluate a successful  outcome?}
                            & \textbf{What are my deadlines for meeting this target?}   \\
    \hline
Jul 2006 & \makecell[tl]{RB-\\DAP-\\01}
    & Understanding structural steel detail drawings and preparing design drawing using AutoCAD
        & Knowledge of load transfer thorough proper detailing and to be represented in drawings
            &  Several structural components and their behaviour under loading; for AutoCAD, needed to learn the commands
                &  Rigorous study of design drawings and draw the details using AutoCAD
                    &  Drawings from previous projects and the software AutoCAD and its manuals
                        & I shall be able to prepare structural detailing using AutoCAD
                            & Sep 2006                      \\
    \hline
    &   &   &   &   &   &   &   &                           \\                                                                                                 &   &   &   &   &   &   &   &                           \\
    &   &   &   &   &   &   &   &                           \\
    \hline
\end{tabularx}
    \end{table}

评论:

  • 为了更好地适应单元格中的文本,您应该考虑使用较小的字体大小。例如\small,甚至footnotesize
  • 对于列头,请尝试使用较短的名称。例如,对于 lat 列,请使用达到这个目标的最后期限是什么时候?而是我们简单地截止日期(在此列的列类型中使用cl

附录: 从下面的评论可以理解,你的表格将会向许多(至少两个)页面发送垃圾邮件。在这种情况下你需要:

  • 删除 float 环境table以供使用,tabularx您应该替换它(或只是添加)包ltablex,它结合了longtabletabularx包的属性
  • 用于保留标准功能(随包tabularx略有改变ltablex
  • 定义第一个和其他表头(如果你想在每一页上重复它们),表脚和最后一个表脚(见下文)

    \documentclass[a4paper,landscape]{article}
    \usepackage[T1]{fontenc}
    \usepackage[margin=24mm,
                bottom= 5mm,%
                footskip=4\baselineskip,
                includefoot,
                % showframe
                ]{geometry}
    \usepackage{caption}
    \usepackage{ragged2e}
    
    \usepackage{array, ltablex, makecell, multirow}
    \keepXColumns
    \renewcommand\theadfont{\bfseries}
    \renewcommand\theadgape{}
    \newcolumntype{L}{>{\RaggedRight}X}
    \newcolumntype{C}{>{\Centering  \arraybackslash}X}
    
    \begin{document}
    
        \begingroup
        \setcellgapes{5pt}
        \makegapedcells
        \setlength\tabcolsep{4pt}
        \small
    \begin{tabularx}{\linewidth}{|c|c|*{6}{L|}>{\raggedright\arraybackslash}p{6em}|}
    \hline
    \multicolumn{9}{|l|}{\textbf{Job role and responsibilities:}}   \\
        \hline
    \multicolumn{5}{|c|}{\textbf{Review of learning needs}}
        & \multicolumn{4}{c|}{\textbf{Development plan}}            \\
        \hline
    \textbf{Date}
        & \textbf{Ref} & \textbf{In what area do  I need to improve my  performance?}
            & \textbf{How does this link to other objectives  (eg employer, ICE,  etc)?}
                & \textbf{What do I need to learn in order to achieve this?}
                    & \textbf{What will I do to achieve this?}
                        & \textbf{What are the likely resources and support that I will need?}
                            & \textbf{How will I evaluate a successful  outcome?}
                                & \textbf{Deadline for meeting this target?}   \\
        \hline
    \endfirsthead
    \hline
    \multicolumn{9}{|l|}{\textbf{Job role and responsibilities (cont.):}}   \\
        \hline
    \multicolumn{5}{|c|}{\textbf{Review of learning needs}}
        & \multicolumn{4}{c|}{\textbf{Development plan}}            \\
        \hline
    \textbf{Date}
        & \textbf{Ref} & \textbf{In what area do  I need to improve my  performance?}
            & \textbf{How does this link to other objectives  (eg employer, ICE,  etc)?}
                & \textbf{What do I need to learn in order to achieve this?}
                    & \textbf{What will I do to achieve this?}
                        & \textbf{What are the likely resources and support that I will need?}
                            & \textbf{How will I evaluate a successful  outcome?}
                                & \textbf{Deadlines for meeting this target?}   \\
        \hline
    \endhead
    \multicolumn{9}{r}{\textit{Continue on the next page:}}   \\
    \endfoot
    \endlastfoot
    Jul 2006 & \makecell[tl]{RB-\\DAP-\\01}
        & Understanding structural steel detail drawings and preparing design drawing using AutoCAD
            & Knowledge of load transfer thorough proper detailing and to be represented in drawings
                &  Several structural components and their behaviour under loading; for AutoCAD, needed to learn the commands
                    &  Rigorous study of design drawings and draw the details using AutoCAD
                        &  Drawings from previous projects and the software AutoCAD and its manuals
                            & I shall be able to prepare structural detailing using AutoCAD
                                & Sep 2006  \\
        \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\  \hline
        &   &   &   &   &   &   &   &           \\
        \hline
    \end{tabularx}
    \endgroup
    
    \end{document}
    

笔记: \begingroup\endgroup用于将表格的某些设置(字体大小、额外的垂直空间)限制在本表内

在此处输入图片描述 在此处输入图片描述

相关内容