我目前正在用 Latex 写我的硕士论文,我有一张宽表,它是横向模式。此外,在表格中,有两行完全是粗体:标题行和最后一行。我遵循这个问题的答案将表格第一行全部设为粗体它对第一行有效,但对最后一行无效。
对于第一行,所有列都是粗体,但对于最后一行,只有第一列是粗体。
有人能帮帮我吗?我正在使用 LuaLatex 和 Miktex 2.9。
我的 MWE 是:
\documentclass[
11pt,
a4paper,
BCOR=15mm,
bibliography=totoc,
DIV=9,
final,
headings=optiontohead,
listof=chaptergapsmall,
listof=totoc,
numbers=noenddot,
openright,
parskip=half,
titlepage,
twoside,
]{scrreprt}
%------------------------------
% DOCUMENT AND ENCODING
%------------------------------
\usepackage[
english,
ngerman
]{babel}
\usepackage{datetime}
\usepackage[
T1
]{fontenc}
\usepackage[
utf8
]{inputenc}
\usepackage[
automark,
ilines
]{scrlayer-scrpage}
%------------------------------
% Tables
%------------------------------
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{tabularx}
%------------------------------
% GRAPHICS
%------------------------------
\usepackage{graphicx}
\usepackage{overpic}
%------------------------------
% FONT, MATH, AND SYMBOLS
%------------------------------
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[
makeroom
]{cancel}
\usepackage{chemfig}
\usepackage{empheq}
\usepackage{icomma}
\usepackage{mathptmx}
\usepackage[
sc,
osf
]{mathpazo}
\usepackage{mathtools}
\usepackage[
version=4
]{mhchem}
\usepackage{nicefrac}
\usepackage[
output-decimal-marker={,},
range-phrase={--},
range-units=single,
output-exponent-marker=\text{E},
retain-explicit-plus
]{siunitx}
%------------------------------
% TEXT
%------------------------------
\usepackage{blindtext}
\usepackage[
font={small,it},
labelfont=bf,
textformat=period,
]{caption}
\usepackage{enumitem}
\usepackage{footnote}
\usepackage[
framemethod=TikZ
]{mdframed}
\usepackage[all]{nowidow}
\usepackage{placeins}
\usepackage[
onehalfspacing
]{setspace}
\usepackage{subcaption}
\usepackage{xcolor}
%------------------------------
% References
%------------------------------
\usepackage[
backref=true,
backrefstyle=three,
bibencoding=utf8,
citestyle=authoryear,
defernumbers=true,
date=year,
doi=true,
giveninits=true,
hyperref=true,
isbn=true,
maxbibnames=99,
sortlocale=auto,
style=authoryear,
uniquename=init,
url=true
]{biblatex}
\usepackage[
babel=true,
strict=true,
english=american,
german=guillemets
]{csquotes}
%------------------------------
% LISTS OF SYMBOLS AND ABBREVIATIONS
%------------------------------
\usepackage[]{acronym}
\usepackage[
intoc,
english
]{nomentbl}
%------------------------------
% CODE
%------------------------------
\usepackage{listings}
\usepackage{scrhack}
%------------------------------
% HYPERREF
%------------------------------
\usepackage[
bookmarks,
bookmarksopen=true,
colorlinks=false,
linkcolor=black,
anchorcolor=black,
citecolor=blue,
filecolor=magenta,
menucolor=black,
linkbordercolor=red,
citebordercolor=blue,
urlbordercolor=cyan,
%pagebackref,
pdfpagelabels,
hypertexnames=true,
linktocpage,
]{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{tablefootnote}
\usepackage{lscape}
\usetikzlibrary{intersections, calc}
\usepackage{filecontents}
\usepackage{adjustbox}
\usepackage{array}
%\usepackage{subfig}
\usepackage{filecontents}
\usepackage{tikz,pgfplots}
\usepackage{soul}
%\usepackage[backend=bibtex,style=numeric-comp,natbib=true,sorting=none]{biblatex}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\begin{document}
\begin{landscape}
\begin{table}[h!]
\resizebox{\pagewidth}{!}{%
\begin{tabular}{$c^c^c^c^c^c^c^c^c^c}
\rowstyle{\bfseries}k0 & 3 & 4 & 11 & 15 & 16 & 21 & 23 & 24 & 25 \\
1 & $\SI{-1,611698E+00}{}$ & $\SI{-5,15900258E-03}{}$ & $\SI{6,30506428E-04}{}$ & $\SI{1,76906828E-03}{}$ & $\SI{1,33663594E-01}{}$ & $\SI{1,48886466E-03}{}$ & $\SI{1,20976955E-01}{}$ & $\SI{1,34041033E-01}{}$ & $\SI{8,82496074E-01}{}$ \\
2 & $\SI{-1,611698E+00}{}$ & $\SI{-5,15900258E-03}{}$ & $\SI{6,26128162E-04}{}$ & $\SI{1,76906828E-03}{}$ & $\SI{1,20297235E-01}{}$ & $\SI{1,49439564E-03}{}$ & $\SI{1,00734380E-01}{}$ & $\SI{1,20636930E-01}{}$ & $\SI{8,71657257E-01}{}$ \\
3 & $\SI{-1,611698E+00}{}$ & $\SI{-5,15900258E-03}{}$ & $\SI{7,66274060E-04}{}$ & $\SI{1,59217479E-03}{}$ & $\SI{1,17781198E-01}{}$ & $\SI{1,50464406E-03}{}$ & $\SI{1,01117973E-01}{}$ & $\SI{1,08573237E-01}{}$ & $\SI{8,71657257E-01}{}$ \\
4 & $\SI{-1,611698E+00}{}$ & $\SI{-5,15900258E-03}{}$ & $\SI{7,94979626E-04}{}$ & $\SI{1,51805768E-03}{}$ & $\SI{1,15181913E-01}{}$ & $\SI{1,52044130E-03}{}$ & $\SI{1,02134836E-01}{}$ & $\SI{1,08573237E-01}{}$ & $\SI{8,80405384E-01}{}$ \\
5 & $\SI{-1,611698E+00}{}$ & $\SI{-5,15900258E-03}{}$ & $\SI{6,68034204E-04}{}$ & $\SI{1,68500964E-03}{}$ & $\SI{1,25576240E-01}{}$ & $\SI{1,52142533E-03}{}$ & $\SI{1,12348319E-01}{}$ & $\SI{9,77159132E-02}{}$ & $\SI{8,80405384E-01}{}$ \\
\rowstyle{\bfseries}Average & $\SI{-1,611698E+00}{}$ & $\SI{-5,159003E-03}{}$ & $\SI{6,946160E-04}{}$ & $\SI{1,635247E-03}{}$ & $\SI{1,216266E-01}{}$ & $\SI{1,493486E-03}{}$ & $\SI{1,031347E-01}{}$ & $\SI{1,128022E-01}{}$ & $\SI{8,425496E-01}{}$
\end{tabular}}
\end{table}
\end{landscape}
\end{document}
答案1
我不会使用adjustbox
机器将表格中的 9 个数据列(每个数据列包含小数点后最多 9 位数字和指数项)挤进文本块的宽度,而是使用程序包的机器siunitx
将所有数字四舍五入为小数点后 3 位数字。(您的读者应该从小数点后 8 位数字中得到什么?三位数应该足够了,对吧?)
使用包的S
列类型允许您摆脱所有$...$
包装器和所有\SI{...}{}
包装器,使输入更加清晰易读。
我还会使用tabular*
环境而不是tabular
环境,以确保表格适合(旋转的)文本块的宽度。
这些调整,以及为表格提供更多的视觉结构,也应该使得使用任何大胆的。
\documentclass[
11pt, a4paper, BCOR=15mm, bibliography=totoc,
DIV=9, final, headings=optiontohead,
listof=chaptergapsmall, listof=totoc,
numbers=noenddot, openright, parskip=half,
titlepage, twoside]{scrreprt}
%% I've simplified the preamble to load only packages relevant for this example
\usepackage[automark,ilines]{scrlayer-scrpage}
\usepackage[english,ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{mathtools,amssymb} % 'mathtools' loads 'amsmath'
%\usepackage{mathptmx} % why do you load this package?
%\usepackage[sc,osf]{mathpazo} % mathpazo is obsolete
\usepackage{newpxtext,newpxmath}
\usepackage[output-decimal-marker={,},
range-phrase={--},
range-units=single,
output-exponent-marker=\text{E},
retain-explicit-plus
]{siunitx}
\usepackage[font={small,it}, labelfont=bf, textformat=period]{caption}
\usepackage[onehalfspacing]{setspace}
\usepackage{array}
\begin{document}
\begin{sidewaystable}
\small % for a 10 percent linear reduction in font size
\setlength\tabcolsep{0pt} % let LaTeX determine intercolumn whitespace
\sisetup{round-mode=places, round-precision=3, retain-zero-exponent} % new
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l
*{9}{S[table-format=-1.3e1]}}
k0 & {3} & {4} & {11} & {15} & {16} & {21} & {23} & {24} & {25} \\
\midrule
1 & -1,611698E+00& -5,15900258E-03& 6,30506428E-04& 1,76906828E-03& 1,33663594E-01& 1,48886466E-03& 1,20976955E-01& 1,34041033E-01& 8,82496074E-01 \\
2 & -1,611698E+00& -5,15900258E-03& 6,26128162E-04& 1,76906828E-03& 1,20297235E-01& 1,49439564E-03& 1,00734380E-01& 1,20636930E-01& 8,71657257E-01 \\
3 & -1,611698E+00& -5,15900258E-03& 7,66274060E-04& 1,59217479E-03& 1,17781198E-01& 1,50464406E-03& 1,01117973E-01& 1,08573237E-01& 8,71657257E-01 \\
4 & -1,611698E+00& -5,15900258E-03& 7,94979626E-04& 1,51805768E-03& 1,15181913E-01& 1,52044130E-03& 1,02134836E-01& 1,08573237E-01& 8,80405384E-01 \\
5 & -1,611698E+00& -5,15900258E-03& 6,68034204E-04& 1,68500964E-03& 1,25576240E-01& 1,52142533E-03& 1,12348319E-01& 9,77159132E-02& 8,80405384E-01 \\
\addlinespace
Avg & -1,611698E+00 & -5,159003E-03 & 6,946160E-04 & 1,635247E-03 & 1,216266E-01 & 1,493486E-03 & 1,031347E-01 & 1,128022E-01 & 8,425496E-01
\end{tabular*}
\end{sidewaystable}
\end{document}
答案2
对于包含数学的行,使用
\rowstyle\bfseries\mathversion{bold}
并添加
\sisetup{detect-weight}
编辑:
另外,如果你确实想使用resizebox
,请写
\resizebox{\textheight}{...}