0

First a minimal working sample is given:

\documentclass[oneside]{ctexbook}
\usepackage[top=3.2cm,bottom=2.4cm,left=2.5cm,right=2.5cm]{geometry} 
\usepackage{lipsum}
%%%实现表格中数字按小数点对齐%%%%%%%%%%%%%%
\usepackage[mode=text]{siunitx}
%mode:math(正文数字old),text(正文数字非old),主要针对表格
%%%解决表格标题与下方表格过近%%%%%%%%%%%%%%
\usepackage{caption}
%%%跨页表格%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{longtable}
%%%表格标题与前后文字间距%%%%%%%%%%%%%%%%%
\setlength{\abovecaptionskip}{2pt} 
\setlength{\belowcaptionskip}{2pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
%%%表格与页面左右边缘之间的矩离均为0%%%%%%%%
\setlength{\LTleft}{0pt} \setlength{\LTright}{0pt} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{longtable}{@{\extracolsep{\fill}} l|c S|S S|S|S|S}%@{\extracolsep{\fill}}设置使得后面所有列间距可以伸展到预定义的表格宽度。
    \hline\hline
    \caption{标准字体命令与字号的对应值} %\label{}加在\caption{}的括号中
    \\\hline\hline
    &\multicolumn{2}{c}{\texttt{zihao=5}}\vline&\multicolumn{2}{c}{\texttt{zihao=-4}}\vline &\texttt{10pt}&\texttt{11pt}&\texttt{12pt}\\\cline{2-8}  
    字体命令&字号&bp值&字号&bp值&pt值&pt值&pt值\\\hline
    \endfirsthead%第一页表头
    \hline
    字体命令&字号&bp值&字号&bp值&pt值&pt值&pt值\\\hline
    \endhead%续页表头
    \verb|\tiny|&七号&5.5&小六&6.5&5&6&6  \\\hline
    \verb|\scriptsize|&小六&6.5&六号&7.5&7&8&8  \\\hline
    \verb|\footnotesize|&六号&7.5&小五&9&8&9&10  \\\hline
    \verb|\small|&小五&9&五号&10.5&9&10&11  \\\hline
    \verb|\normalsize|&五号&10.5&小四&12&10&11&12  \\\hline
    \verb|\large|&小四&12&小三&15&12&12&14  \\\hline
    \verb|\Large|&小三&15&小二&18&14&14&17  \\\hline
    \verb|\LARGE|&小二&18&二号&22&17&17&20  \\\hline
    \verb|\huge|&二号&22&小一&24&20&20&25  \\\hline
    \verb|\Huge|&一号&26&一号&26&25&25&25  \\\hline
\end{longtable}
\end{document}

Compiled with XeLatex, I got a pdf as follows

enter image description here

My QUESTIONS are:

  1. How to make the cline (the line below zihao=5) from the first vertical line?
  2. How to make the texts of column 6-8 centering?

Any help is welcome!

1

1: \cline{2-8} instead of \hline.

2: change the format of numbers. For columns 6-8, it should be S[table-format=2.0]. For columns 3 and 5, S[table-format=2.1]. I don't see why you use an S column type for columns 2 and 4 since they have no numbers to align. Add in the preamble \sisetup{table-number-alignment=center}Last : in an S column, non number contents (e.g. column heads) are centred by adding a pair of braces around the contents (except in case of \multicolumn).

  • For your 1, it seems that your don't read my codes clearly; and for your 2, it doesn't work! – Mogic Jan 19 '18 at 1:21
  • Your code is not fully clear to me, I confess, as I don't read Chinese. However for point 2, I gave you the standard answer for european languages. For point 1, I had not seen your code indeed. Maybe this is due to @{\extracolsep{\fill}} in the preamble of the table. It can result in strange things sometimes. What happens if you remove it? – Bernard Jan 19 '18 at 1:41
  • It may become well, but I want to make the table have a length of textwidth in long table environment. – Mogic Jan 19 '18 at 2:13
  • Why don't use use tabularx , loading the ltablex package (it brings the functionalities of long table to tabularx)? – Bernard Jan 19 '18 at 10:38
  • Because I need the table to be broken by page. – Mogic Jan 19 '18 at 11:16

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.