我无法使长表第一列的文本正确对齐。
问题是,在换行符(自动)之后,文本会缩进。更像是反向缩进,因为它比第一行更靠左对齐。我想避免这种情况,但找不到可行的解决方案。在过去的三个小时里,我尝试通过 \newcolumntype 和其他一些东西进行重新定义,现在我正式放弃了 :D 希望有人能帮忙。
这是我的 MWE,其中奇怪的对齐发生在第一行:
\documentclass[11pt,a4paper,twoside]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{ragged2e,array,longtable}
\begin{document}
\begin{longtable}{|@{}p{0.35\textwidth}|p{0.15\textwidth}|p{0.5\textwidth}|}
\firsthline
\rule[-1ex]{0pt}{2.5ex} \textbf{Software} & \textbf{Version} &
\textbf{Copyright} \\\hline
\hline
\rule[-1ex]{0pt}{2.5ex} Bio-Formats Package for ImageJ & 5.0.4 & The Open
Microscopy Environment \\
\hline
\rule[-1ex]{0pt}{2.5ex} GraphPad Prism 6 & 6.00 & GraphPad Software Inc., La
Jolla, CA, USA \\
\hline
\rule[-1ex]{0pt}{2.5ex} Heidelberg Eye Explorer & 1.9.13.0 & Heidelberg
Engineering GmbH, Heidelberg, Germany \\
\hline
\rule[-1ex]{0pt}{2.5ex} ImageJ & 1.45s & Wayne Rasband, NIH, Bethesda, MD,
USA \\
\hline
\rule[-1ex]{0pt}{2.5ex} Matlab & R2016a & The MathWorks Inc., Natick, MA,
USA \\
\hline
\rule[-1ex]{0pt}{2.5ex} MC\_Rack & 4.5.9 & Multi Channel Systems MCS GmbH,
Reutlingen, Germany \\
\hline
\rule[-1ex]{0pt}{2.5ex} MC\_DataTool & 2.6.15 & Multi Channel Systems MCS
GmbH, Reutlingen, Germany \\
\hline
\rule[-1ex]{0pt}{2.5ex} Mendeley Desktop & 1.16.1 & Mendeley Desktop Ltd. \\
\hline
\rule[-1ex]{0pt}{2.5ex} NeuroExplorer & 4.125 & Nex Technologies, Madison,
AL, USA \\
\hline
\rule[-1ex]{0pt}{2.5ex} Offline Sorter & 3.3.2 & Plexon Inc., Dallas, TX,
USA \\
\hline
\rule[-1ex]{0pt}{2.5ex} RC\_menu & V6.11.0.20 & Roland Consult Stasche \&
Finger GmbH, Brandenburg a.d. Havel, Germany \\
\hline
\rule[-1ex]{0pt}{2.5ex} SAS statistical analysis software & 9.4 TS Level 1M3
& SAS Institute Inc., Cary, NC, USA \\
\hline
\rule[-1ex]{0pt}{2.5ex} Texmaker & 4.2 & Pascal Brachet \\
\lasthline \\
\caption[Software]{}
\label{tab:Software}
\end{longtable}
\end{document}
非常感谢!
米娜
答案1
您的餐桌的替代方案:
\documentclass[11pt,a4paper,twoside]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{ragged2e}
\usepackage{booktabs, longtable, makecell}
\renewcommand\theadfont{\bfseries}
\setcellgapes{5pt} % <--- increase
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
\begin{document}
\lipsum[1-3]
\begingroup
\makegapedcells
\begin{longtable}{@{}
>{\RaggedRight}p{\dimexpr0.27\linewidth-1.33\tabcolsep\relax}% 1.33 ~ 4/3 \tabcolsep per column
>{\RaggedRight}p{\dimexpr0.23\linewidth-1.33\tabcolsep\relax}
>{\RaggedRight}p{\dimexpr0.50\linewidth-1.33\tabcolsep\relax}
@{} }
\caption[Software]{Overview of software packages ... }
\label{tab:Software} \\
\toprule
\textbf{Software} & \textbf{Version} & \textbf{Copyright} \\
\midrule
\endfirsthead
\caption{Overview of software packages ... (cont.) }
\label{tab:Software} \\
\toprule
\textbf{Software} & \textbf{Version} & \textbf{Copyright} \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{\textit{continue on the next page}}
\endfoot
\bottomrule
\endlastfoot
Bio-Formats Package for ImageJ
& 5.0.4 & The Open Microscopy Environment \\
GraphPad Prism 6 & 6.00 & GraphPad Software Inc., La Jolla, CA, USA \\
Heidelberg Eye Explorer & 1.9.13.0 & Heidelberg Engineering GmbH, Heidelberg, Germany \\
ImageJ & 1.45s & Wayne Rasband, NIH, Bethesda, MD, USA \\
Matlab & R2016a & The MathWorks Inc., Natick, MA, USA \\
MC\_Rack & 4.5.9 & Multi Channel Systems MCS GmbH, Reutlingen, Germany \\
MC\_DataTool & 2.6.15 & Multi Channel Systems MCS GmbH, Reutlingen, Germany \\
Mendeley Desktop & 1.16.1 & Mendeley Desktop Ltd. \\
NeuroExplorer & 4.125 & Nex Technologies, Madison, AL, USA \\
Offline Sorter & 3.3.2 & Plexon Inc., Dallas, TX, USA \\
RC\_menu & V6.11.0.20& Roland Consult Stasche \& Finger GmbH, Brandenburg a.d. Havel, Germany \\
SAS statistical analysis software
& 9.4 TS Level 1M3
& SAS Institute Inc., Cary, NC, USA \\
Texmaker & 4.2 & Pascal Brachet \\
\end{longtable}
\endgroup
\end{document}
这使
关于rules
在您的表格中使用的,请阅读我在您的问题下面的评论。
编辑:
添加了表头、末头、表尾和末尾的代码。略微减少了\arraystreatch
(行变得更紧凑)并增加了单元格中的垂直空间。现在行更加清晰可见,并且行与行之间不再使用线条。
答案2
摆脱神秘的\rule[-1ex]{0pt}{2.5ex}
指令是一个很好的第一步。如果你仔细观察,你会发现longtable
比文本块更宽;有必要减少一些列宽。另外,请将所有三列从完全对齐更改为右对齐布局。
\documentclass[11pt,a4paper,twoside]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{ragged2e,array,longtable}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\setlength\extrarowheight{2pt}
\begin{document}
\begin{longtable}{|P{0.29\textwidth}|P{0.14\textwidth}|P{0.48\textwidth}|}
\hline
\textbf{Software} & \textbf{Version} & \textbf{Copyright} \\
\hline\hline
\endhead
Bio-Formats Package for ImageJ & 5.0.4
& The Open Microscopy Environment \\
\hline
GraphPad Prism 6 & 6.00
& GraphPad Software Inc., La Jolla, CA, USA \\
\hline
Heidelberg Eye Explorer & 1.9.13.0
& Heidelberg Engineering GmbH, Heidelberg, Germany \\
\hline
ImageJ & 1.45s
& Wayne Rasband, NIH, Bethesda, MD, USA \\
\hline
Matlab & R2016a
& The MathWorks Inc., Natick, MA, USA \\
\hline
MC\_Rack & 4.5.9
& Multi Channel Systems MCS GmbH, Reutlingen, Germany \\
\hline
MC\_DataTool & 2.6.15
& Multi Channel Systems MCS GmbH, Reutlingen, Germany \\
\hline
Mendeley Desktop & 1.16.1
& Mendeley Desktop Ltd. \\
\hline
NeuroExplorer & 4.125
& Nex Technologies, Madison, AL, USA \\
\hline
Off{}line Sorter & 3.3.2
& Plexon Inc., Dallas, TX, USA \\
\hline
RC\_menu & V6.11.0.20
& Roland Consult Stasche \& Finger GmbH, Brandenburg a.d.\ Havel, Germany \\
\hline
SAS statistical analysis software & 9.4 TS Level 1M3
& SAS Institute Inc., Cary, NC, USA \\
\hline
Texmaker & 4.2 & Pascal Brachet \\
\hline
\caption[Software]{Software}
\label{tab:Software}
\end{longtable}
\end{document}