表格中的单词之间左对齐且无额外空格

表格中的单词之间左对齐且无额外空格

以下是示例代码:

\documentclass[letterpaper, 10pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{array}
\usepackage[none]{hyphenat}
\begin{document}

\begin{center}
\begin{tabular}{|m{4.5cm}|m{1.2cm}<{\centering}|m{8cm}|c|}
\hline
\centering \textbf{Course Name} & \centering \textbf{Date} & \centering \textbf{Textbook} & \centering \textbf{Grade} \tabularnewline \hline

C Programming Language \& Lab & 09/2009 - 12/2009 & Brian W. Kernighan, and Dennis M. Ritchie, \textit{The C Programming Language}, 2nd ed. ISBN:9780131103627 & 89 \\ \hline

Integrative Practice on Courses & 07/2011 & LUPA, \textit{Linux Software Engineer}, ISBN:9787030199645 & 87 \\ \hline
\end{tabular}
\end{center}

\end{document}

如生成的 PDF 所示,由于我禁用了自动连字,所以有些单词之间的空格太多。我想在单词之间只留一个空格,而不进行两端对齐。

答案1

您可以\raggedright对感兴趣的列使用对齐方式:

在此处输入图片描述

\documentclass[letterpaper, 10pt]{article}
\usepackage[margin=1in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{array}% http://ctan.org/pkg/array
\usepackage[none]{hyphenat}% http://ctan.org/pkg/hyphenat
\begin{document}

\begin{center}
  \begin{tabular}{|m{4.5cm}|m{1.2cm}<{\centering}|m{8cm}|c|}
    \hline
    \centering \textbf{Course Name} & \centering \textbf{Date} & \centering \textbf{Textbook} & \centering \textbf{Grade} \tabularnewline
    \hline
    C Programming Language \& Lab & 09/2009 - 12/2009 & 
      Brian W. Kernighan, and Dennis M. Ritchie, \textit{The C Programming Language}, 2nd ed. ISBN:9780131103627 & 89 \\
    \hline
    Integrative Practice on Courses & 07/2011 & LUPA, \textit{Linux Software Engineer}, ISBN:9787030199645 & 87 \\
    \hline
  \end{tabular}
\end{center}

\begin{center}
  \begin{tabular}{|>{\raggedright}m{4.5cm}|>{\centering}m{1.2cm}|>{\raggedright}m{8cm}|c|}
    \hline
    \centering \textbf{Course Name} & \centering \textbf{Date} & \centering \textbf{Textbook} & \centering \textbf{Grade} \tabularnewline
    \hline
    C Programming Language \& Lab & 09/2009 - 12/2009 & 
      Brian W. Kernighan, and Dennis M. Ritchie, \textit{The C Programming Language}, 2nd ed. ISBN:9780131103627 & 89 \\
    \hline
    Integrative Practice on Courses & 07/2011 & LUPA, \textit{Linux Software Engineer}, ISBN:9787030199645 & 87 \\
    \hline
  \end{tabular}
\end{center}

\end{document}

相关内容