我在环境内部遇到了一点排版问题longtable
。
我正在写简历,需要在表格单元格内写一份技能列表。由于我想将文档长度控制在一页以内,因此我不会使用itemize
连字符 (“-”) 来节省空间,因此我手动用连字符 (“-”) 写了这份列表。
我注意到,如果连字符是表格单元格中的第一个字符,则第一行会缩进一个空格,而如果列表前有一些文本,则所有内容都会正确显示。
我注意到注释掉\usepackage{microtype}
可以解决这个问题,但我想使用该包,因为否则间距看起来不太好。
以下是我所拥有的一个示例:
\documentclass[a4paper,12pt,]{report}
\usepackage[swedish, italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage{pslatex}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage[round]{natbib}
\usepackage{microtype}
\usepackage{longtable}
\usepackage[top=2cm, bottom=2cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage{array}
\renewcommand{\baselinestretch}{1.05}
\renewcommand*{\familydefault}{\sfdefault}
%----------------------------------------
\begin{document}
\pagenumbering{gobble}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{3.5cm}}
\begin{longtable}{Rp{11cm}}
\textbf{Education}&\\
2010 - 2014 &\textbf{University and degree}
- One course
- Another course
- Some interesting seminar\\
\textbf{Computer skills}&\\
&- Operating systems: Windows, Linux
- Other software
- Other software
\end{longtable}
\end{document}
正如您在图片中看到的,如果连字符(“大学和学位”)之前有一些文本,则列表显示正确,但以“操作系统”开头的行会缩进。
那么,如何才能去掉连字符前的空格而不用注释掉呢microtype
?
编辑:我发现可以通过在\hspace{-2pt}
缩进行前添加来手动修复此问题,但我仍然想找到一种合适的方法来做到这一点。非常感谢!
答案1
\\
在每行末尾使用(双反斜杠),并插入&
(列分隔符) 可解决您遇到的问题。顺便说一句,正如@egreg 在评论中指出的那样,您不应该使用-
;至少,请考虑使用短划线(通过键入 创建--
)。
\documentclass[a4paper,12pt]{report}
\usepackage[swedish, italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage{pslatex}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage[round]{natbib}
\usepackage{microtype}
\usepackage{longtable}
\usepackage[vmargin=2cm,hmargin=2.5cm]{geometry}
\usepackage{array}
\renewcommand{\baselinestretch}{1.05}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
\pagenumbering{gobble}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{3.5cm}}
\begin{longtable}{Rp{11cm}}
\textbf{Education}&\\
2010--2014 &\textbf{University and degree} \\
&-- One course\\
&-- Another course\\
&-- Some interesting seminar\\[1ex]
\textbf{Computer skills}\\
&-- Operating systems: Windows, Linux\\
&-- Other software\\
&-- Other software\\
\end{longtable}
\end{document}
附录:我相信上面使用环境获得的结果longtable
也可以使用环境获得tabular
。在下面的示例中,我首先将材料排版为longtable
(默认情况下居中),然后在备份并切换到红色后,使用tabular
。
\documentclass[a4paper,12pt]{report}
\usepackage[swedish, italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage{xcolor} % load this package so that "tabular" env. can be typeset in red
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage[round]{natbib}
\usepackage{microtype}
\usepackage{longtable}
\usepackage[vmargin=2cm,hmargin=2.5cm]{geometry}
\usepackage{array}
\renewcommand{\baselinestretch}{1.05}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
\pagenumbering{gobble}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{3.5cm}}
\begin{longtable}{Rp{11cm}}
\textbf{Education}&\\
2010--2014 &\textbf{University and degree} \\
&-- One course\\
&-- Another course\\
&-- Some interesting seminar\\[1ex]
\textbf{Computer skills}\\
&-- Operating systems: Windows, Linux\\
&-- Other software\\
&-- Other software\\
\end{longtable}
\centering
\vspace{-5.46cm} % vertical adjustment, to overlayed the tabular on the longtable
\color{red}
\begin{tabular}{Rp{11cm}}
\textbf{Education}&\\
2010--2014 &\textbf{University and degree} \\
&-- One course\\
&-- Another course\\
&-- Some interesting seminar\\[1ex]
\textbf{Computer skills}\\
&-- Operating systems: Windows, Linux\\
&-- Other software\\
&-- Other software\\
\end{tabular}
\end{document}
答案2
问题是,microtype
连字符和破折号会突出到页边距。让我们看几个例子:
\documentclass{article}
\usepackage{microtype,longtable}
\begin{document}
\setlength{\tabcolsep}{0pt} % no intercolumn space to show the problem
\begin{longtable}{l|p{3cm}}
xxx &- abc
- abc\\
\end{longtable}
\centering % longtable centers!
\begin{tabular}{l|p{3cm}}
xxx &- abc
- abc\\
\end{tabular}
\end{document}
因此,“操作系统”行中没有额外的空间,而是没有突出部分(longtable
对列进行了一些技巧p
)。以下连字符稍微向左。
解决方案:
\newcommand{\itemdash}{\mbox{\kern0pt--}}
我使用短破折号代替连字符,这样风格上更好。
以下是完整示例
\documentclass{article}
\usepackage{microtype,longtable}
\newcommand{\itemdash}{\mbox{\hspace{0pt}--}}
\begin{document}
\setlength{\tabcolsep}{0pt} % no intercolumn space to show the problem
\begin{longtable}{l|p{3cm}}
xxx &\itemdash\ abc
\itemdash\ abc\\
\end{longtable}
\centering % longtable centers!
\begin{tabular}{l|p{3cm}}
xxx &\itemdash\ abc
\itemdash\ abc\\
\end{tabular}
\end{document}
如果您\itemdash
在代码中实现它,那就没问题了。
答案3
不确定微类型在那里做什么,但你可以用一个框和零空间来隐藏它:
\documentclass[a4paper,12pt,]{report}
\usepackage[swedish, italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage{pslatex}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage[round]{natbib}
\usepackage{microtype}
\usepackage{longtable}
\usepackage[top=2cm, bottom=2cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage{array}
\renewcommand{\baselinestretch}{1.05}
\renewcommand*{\familydefault}{\sfdefault}
%----------------------------------------
\begin{document}
\pagenumbering{gobble}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{3.5cm}}
\begin{longtable}{Rp{11cm}}
\textbf{Education}&\\
2010 -- 2014 &\textbf{University and degree}
\hskip0pt-- One course
\hskip0pt-- Another course
\hskip0pt-- Some interesting seminar\\
\textbf{Computer skills}&\\
&\hskip0pt-- Operating systems: Windows, Linux
\hskip0pt-- Other software
\hskip0pt-- Other software
\end{longtable}
\end{document}
答案4
您可以使用itemize
环境以及包的wide
和选项。我给出了两种变体,以考虑破折号突出部分:nosep
enumitem
\documentclass[a4paper,12pt,]{report}
\usepackage[italian]{babel}%swedish,
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage[round]{natbib}
\usepackage{microtype}
\usepackage{longtable}
\usepackage[vmargin=2cm, hmargin=2.5cm]{geometry}
\usepackage{array}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{3.5cm}}
\usepackage{enumitem}
\usepackage{setspace}
\setstretch{1.05}
\renewcommand*{\familydefault}{\sfdefault}
%----------------------------------------
\begin{document}
\pagenumbering{gobble}
{\setlist[itemize,1]{label=\textendash, wide =0.6em, nosep}
\begin{longtable}{R p{11cm}}
\textbf{Education}&\\
2010 - 2014 &\textbf{University and degree}
\begin{itemize}
\item One course
\item Another course
\item Some interesting seminar
\end{itemize}\\[-\topsep]
\textbf{Computer skills}
& \leavevmode\vspace{-\baselineskip}
\begin{itemize}
\item Operating systems: Windows, Linux
\item Other software
\item Other software
\end{itemize}
\end{longtable}}
{\setlist[itemize,1]{label = \,\textendash, wide, nosep}
\begin{longtable}{R p{11cm}}
\textbf{Education}&\\
2010 - 2014 &\textbf{University and degree}
\begin{itemize}
\item One course
\item Another course
\item Some interesting seminar
\end{itemize}\\[-\topsep]
\textbf{Computer skills}
& \leavevmode\vspace{-\baselineskip}
\begin{itemize}
\item Operating systems: Windows, Linux
\item Other software
\item Other software
\end{itemize}
\end{longtable}}
\end{document}