字幕中的数学间距

字幕中的数学间距

看起来字幕中的数学被拉长了,如图 2、3 和 4 所示:

在此处输入图片描述

pdflatex问题在第二次运行时出现。

给出的解决方案在数学模式下锁定间距添加额外的花括号${y = mx + b}$是可行的,但想知道是否有更好的标题解决方案。

为了使文本对齐,稍微拉伸一下是可以的,但在这种情况下,这似乎不是问题,而且拉伸似乎很大。

参考:

代码:

\documentclass{article}
\usepackage{showframe}
\usepackage{graphicx}

\usepackage{caption}

\DeclareCaptionStyle{mystyle}
  {format=plain,%
    font=footnotesize,
    textformat=period,
    justification=RaggedRight,
    singlelinecheck=true,
  }% all captions are left aligned

\DeclareCaptionStyle{singlelinecentered}
  [justification=Centering]% centered if single line and no `singlelinecheck=false`
  {style=mystyle}% other captions are left aligned

\DeclareCaptionStyle{singlelineraggedleft}
  [justification=RaggedLeft]% right aligned if single line and no `singlelinecheck=false`
  {style=mystyle}% other captions are left aligned

\captionsetup{style=singlelineraggedleft}

\begin{document}
\noindent
\begin{minipage}{0.5\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth, height=2cm]{example-image}%
    \captionsetup{width=0.95\linewidth}%
    \captionsetup{singlelinecheck=false}%
    \captionof{figure}{$y=mx+b$ on Left}%
\end{minipage}%
\begin{minipage}{0.5\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth, height=2cm]{example-image}%
    \captionsetup{width=0.95\linewidth}%
    \captionof{figure}{$y=mx+b$ on Right}%
\end{minipage}%

\medskip\noindent
\begin{minipage}[t]{0.5\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth, height=2cm]{example-image}%
    \captionsetup{width=0.95\linewidth,style=singlelinecentered}%
    \captionof{figure}{$y=mx+b$}%
\end{minipage}%
\begin{minipage}[t]{0.5\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth, height=2cm]{example-image}%
    \captionsetup{width=0.95\linewidth}%
    \captionof{figure}{$y=mx+b$}%
\end{minipage}%
\end{document}

答案1

我认为没有什么奇怪的,这与数学无关,而是与ragged2e它的工作原理有关。

  1. \RaggedRight\RaggedLeft\Centering上下文中,该\spaceskip参数设置为\spaceskip\fontdimen2\font,即当前字体的正常单词间空间,但不进行任何拉伸和收缩。

  2. \RaggedRight上下文中, 的值\rightskip设置为\RaggedRightRightskip(默认); 对和 也0pt plus 2em进行了类似的设置。\RaggedLeft\Centering

  3. \linewidth-2em比 ( )短的标题\RaggedRight需要拉长。

  4. 唯一的可拉伸性存在于二元运算和关系符号周围的空间中。

  5. 嘿!只是数学太夸张了。

解决方法:不要使用ragged2e此方法。

替代解决方案:消除和的可拉伸性和可收缩性\medmuskip\thickmuskip

\documentclass{article}
\usepackage{showframe}
\usepackage{graphicx}

\usepackage{ragged2e}
\usepackage{caption}
\usepackage{etoolbox}

\csappto{@raggedtwoe@everyselectfont}{%
  \medmuskip=1\medmuskip
  \thickmuskip=1\thickmuskip
}

\DeclareCaptionStyle{mystyle}{
  format=plain,
  font=footnotesize,
  textformat=period,
  justification=RaggedRight,
  singlelinecheck=true,
  }% all captions are left aligned

\DeclareCaptionStyle{singlelinecentered}
  [justification=Centering]% centered if single line and no `singlelinecheck=false`
  {style=mystyle}% other captions are left aligned

\DeclareCaptionStyle{singlelineraggedleft}
  [justification=RaggedLeft]% right aligned if single line and no `singlelinecheck=false`
  {style=mystyle}% other captions are left aligned

\captionsetup{style=singlelineraggedleft}

\begin{document}
\noindent
\begin{minipage}{0.5\linewidth}
    \captionsetup{width=0.95\linewidth}%
    \captionsetup{singlelinecheck=false}%
    \centering
    \includegraphics[width=0.95\linewidth, height=2cm]{example-image}
    \captionof{figure}{$y=mx+b$ on Left}
\end{minipage}%
\begin{minipage}{0.5\linewidth}
    \captionsetup{width=0.95\linewidth}%
    \centering
    \includegraphics[width=0.95\linewidth, height=2cm]{example-image}
    \captionof{figure}{$y=mx+b$ on Right}
\end{minipage}

\medskip\noindent
\begin{minipage}[t]{0.5\linewidth}
    \captionsetup{width=0.95\linewidth,style=singlelinecentered}%
    \centering
    \includegraphics[width=0.95\linewidth, height=2cm]{example-image}%
    \captionof{figure}{$y=mx+b$}%
\end{minipage}%
\begin{minipage}[t]{0.5\linewidth}
    \captionsetup{width=0.95\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth, height=2cm]{example-image}
    \captionof{figure}{$y=mx+b$}
\end{minipage}

\end{document}

\hbox但是对于每个简短的标题,您都会收到“未满”的消息。

在此处输入图片描述

相关内容