使用 cals 表中的 courier 将段落分成几行

使用 cals 表中的 courier 将段落分成几行
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{top=10mm, bottom=10mm, left=10mm, right=10mm}
\geometry{showframe}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{cals}

\makeatletter

\begin{document}
%\renewcommand*\familydefault{\sfdefault}
\renewcommand*\familydefault{\ttdefault}
\normalfont

\begin{calstable}

\colwidths{
{15pt}
{10pt}
{515.60239pt}
}
\cals@paddingL=1pt
\cals@paddingR=1pt
\def\cals@borderT{0.2pt}
\def\cals@borderB{0.2pt}
\def\cals@borderL{0.2pt}
\def\cals@borderR{0.2pt}
\brow
\alignR \cell{\strut E}
\alignC \cell{\strut =}
\alignL \cell{\strut this is the english text, this is the english text, this is the english text, this is the english text, this is the english text, this is the english text, this is the english text}
\erow

\end{calstable}

Why doesn't the text break in the rigth place? In case of using sfdeault, it's good. 
\end{document}

答案1

这类似于如何打破较长的 \texttt 部分。默认情况下,tt字体没有可拉伸的单词间距,因此 TeX 在选择换行符时没有太多的回旋余地。增加一些可拉伸性可以改善换行效果:

示例输出

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{top=10mm, bottom=10mm, left=10mm, right=10mm}
\geometry{showframe}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{cals}
\makeatletter

\newcommand*\flextt{%
  \ttfamily
  \fontdimen2\font=0.4em% interword space
  \fontdimen3\font=0.2em% interword stretch
  \fontdimen4\font=0.1em% interword shrink
  \fontdimen7\font=0.1em% extra space
}

\begin{document}
\flextt

\begin{calstable}

\colwidths{
{15pt}
{10pt}
{515.60239pt}
}
\cals@paddingL=1pt
\cals@paddingR=1pt
\def\cals@borderT{0.2pt}
\def\cals@borderB{0.2pt}
\def\cals@borderL{0.2pt}
\def\cals@borderR{0.2pt}
\brow
\alignR \cell{\strut E}
\alignC \cell{\strut =}
\alignL \cell{\strut this is the english text, this is the english text, this is the english text, this is the english text, this is the english text, this is the english text, this is the english text}
\erow

\end{calstable}

Why doesn't the text break in the rigth place? In case of using sfdeault, it's good. 
\end{document}

答案2

尝试在字体中分解单词始终是一件大事tt

您可以尝试使用sloppypar环境:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{top=10mm, bottom=10mm, left=10mm, right=10mm}
\geometry{showframe}
\usepackage{courier}
\usepackage[T1]{fontenc}
\usepackage{cals}

\makeatletter

\begin{document}
%\renewcommand*\familydefault{\sfdefault}
\renewcommand*\familydefault{\ttdefault}
\normalfont

\begin{calstable}

\colwidths{
{15pt}
{10pt}
{515.50239pt}
}
\cals@paddingL=1pt
\cals@paddingR=1pt
\def\cals@borderT{0.2pt}
\def\cals@borderB{0.2pt}
\def\cals@borderL{0.2pt}
\def\cals@borderR{0.2pt}
\brow
\alignR \cell{\strut E}
\alignC \cell{\strut =}
\alignL \cell{\begin{sloppypar}\strut this is the english text, this is the english text, 
this is the english text, this is the english text, this is the english text, 
this is the english text, this is the english text\end{sloppypar}}
\erow

\end{calstable}

Why doesn't the text break in the rigth place? In case of using sfdeault, it's good.
\end{document}

输出:

在此处输入图片描述

相关内容