如何使用“longtable”避免文本与相邻列重叠

如何使用“longtable”避免文本与相邻列重叠

我需要在开始时使用相同的格式(或非常相似的格式),\begin{longtable}{...}最好\mylenght使用与我以前的问题的建议修复中相同的定义:

第一个问题在这里解决...

以下是 MWE:

\documentclass[a4paper,10pt,oneside,openany]{book} 

\usepackage[utf8]{inputenc} % allow specify input encoding
\usepackage[margin=1in]{geometry} % page dimensions

\usepackage{array,longtable} 
\newlength\mylength
\setlength\mylength{\dimexpr(\textwidth-17\arrayrulewidth-32\tabcolsep)/16\relax}
\begin{document} 


\begin{longtable}{|*{16}{>{\centering\arraybackslash}m{\mylength}|}} 
\hline 
\multicolumn{16}{|c|}{\textbf{  Title goes here  } } 
\endhead 
\hline 
{\centering  15  } & 
{\centering  14  } & 
{\centering  13  } & 
{\centering  12  } & 
{\centering  11  } & 
{\centering  10  } & 
{\centering  9  } & 
{\centering  8  } & 
{\centering  7  } & 
{\centering  6  } & 
{\centering  5  } & 
{\centering  4  } & 
{\centering  3  } & 
{\centering  2  } & 
{\centering  1  } & 
{\centering  0  } \\ 
\hline 
\multicolumn{4}{|>{\centering\arraybackslash}m{\dimexpr4\mylength+4\tabcolsep+\arrayrulewidth}|}{ SEPTEMBER  } & 
{\centering  Lists 3 Ready  } & 
{\centering  Lists 2 Ready  } & 
{\centering  Lists 1 Ready  } & 
{\centering  Lists 0 Ready  } & 
\multicolumn{4}{|>{\centering\arraybackslash}m{\dimexpr4\mylength+4\tabcolsep+\arrayrulewidth}|}{ SEPTEMBER  } & 
{\centering  Lists 3 Not Empty  } & 
{\centering Not Empty  } & 
{\centering Not Empty  } & 
{\centering Not Empty  } \\ 
\hline 
\end{longtable} 


\end{document} 

非常感谢您的帮助。谢谢!

答案1

“空”字比你的大,\mylength你必须想一想如何解决这个问题。最简单的方法当然是减小字体大小。

在下面的代码中,我把所有内容都放到了表格中,而没有改变字体大小。不太美观。

% arara: pdflatex

\documentclass[a4paper,10pt,oneside,openany]{book} 
\usepackage[utf8]{inputenc}
\usepackage[english]{babel} % I was hoping for some automatic breaks but this did nor work for "empty"
\usepackage{ragged2e} % I was hoping for some automatic breaks but this did nor work for "empty"
\usepackage{microtype}
\usepackage[margin=1in]{geometry} % page dimensions
\usepackage{array,longtable} 
\newlength\mylength
\setlength\mylength{\dimexpr(\textwidth-17\arrayrulewidth)/16\relax}

\begin{document}    
\begin{longtable}{|*{16}{@{}>{\Centering\arraybackslash}m{\mylength}@{}|}} 
    \hline 
    \multicolumn{16}{|c|}{\textbf{Title goes here}} 
    \endhead 
    \hline 
    $15$ & $14$ & $13$ & $12$ & $11$ & $10$ & $9$ & $8$ & $7$ & $6$ & $5$ & $4$ & $3$ & $2$ & $1$ & $0$ \\ 
    \hline 
    \multicolumn{4}{|c|}{SEPTEMBER} & 
    Lists 3 Ready & 
    Lists 2 Ready & 
    Lists 1 Ready & 
    Lists 0 Ready & 
    \multicolumn{4}{c|}{SEPTEMBER} & % here was one | too much
    Lists 3 Not Emp-ty & 
    Not Emp-ty & 
    Not Emp-ty & 
    Not Emp-ty \\ 
    \hline 
\end{longtable}

在此处输入图片描述

相关内容