如何强制在浮动图形标题中使用连字符?

如何强制在浮动图形标题中使用连字符?

我有一个右浮动图形,其对齐标题跨越四行,如下所示:

看起来像什么 它应该是什么样子

不幸的是,LaTeX 不会对标题中的单词使用连字符(在普通文本中,两个单词都可以使用连字符),尽管仅从目测来看,空间似乎绰绰有余。我尝试将单词添加到命令中\hypenate,添加软连字符"-并手动分隔单词,例如“Un- terschiedliche”。但都不起作用。

我尝试增加 的宽度wrapfigure,但仍然没有效果(下图左侧)。在另一幅图中wrapfigure(下图右侧),它似乎工作正常,唯一的区别是标题文本以及图像和图形本身的宽度。

更多 wrapfigure 宽度 - 没有 不同的图像-有效!

有没有办法力量LaTeX 在特定音节处使用连字符?在标题名称/编号后添加文本会受到惩罚吗?

第一个浮点数的代码:

\begin{wrapfigure}{r}{0.25\textwidth}
    \centering
    \includegraphics[width=0.2\textwidth]{images/4_eadogm_footprints}
    \caption[Unterschiedliche Abmessungen der EA-DOGM-LCDs]{Unterschiedliche Abmessungen der EA-DOGM-LCDs.}
    \label{fig:4_eadogm_footprints}
    \vspace{-10pt}
\end{wrapfigure}

我意识到,如果没有 MWE,几乎不可能确定我的错误。我正在使用模板,不幸的是,我不知道如何编写一个所有设置都完整的 MWE。

任何帮助将不胜感激。

更新:上传图片以显示其内容应该看起来像,渲染{0.33\textwidth}和工作图像。

答案1

使用babel

\caption[Unterschiedliche Abmessungen der EA-DOGM-LCDs]{%
         Unterschiedliche Abmessungen der EA"=DOGM"=LCDs.}

或者至少:

\caption[Unterschiedliche Abmessungen der EA-DOGM-LCDs]{%
         Unterschiedliche Abmessungen der EA-DOGM"=LCDs.}

对于德语文本,如果单词带连字符,则应始终这样做。对于小文本列,请使用 packageragged2e\RaggedRight作为标题。可以使用\captionsetup和 package自动设置caption

由于你没有提供完全的例如,很难说出问题是什么。这是有效的:

\documentclass[ngerman,a4paper]{book}
\usepackage{libertine}
\usepackage{microtype}
\usepackage{babel}
\usepackage{geometry}

\usepackage{blindtext}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\setcounter{chapter}{4}
\setcounter{figure}{11}
\begin{document}

\begin{wrapfigure}{r}{0.25\textwidth}
    \centering
    \includegraphics[width=0.2\textwidth]{images/4_eadogm_footprints}
    \caption[Unterschiedliche Abmessungen der EA-DOGM-LCDs]{Unterschiedliche Abmessungen der EA"=DOGM"=LCDs.}
    \label{fig:4_eadogm_footprints}
    \vspace{-10pt}
\end{wrapfigure}
\blindtext

\end{document}

在此处输入图片描述

答案2

好吧,我相信已经找到了原因和可行的解决方案。根据段落的第一个单词从不带连字符。表格中的窄列似乎也存在同样的问题。

为了欺骗 LaTeX,只需在第一个单词前插入一个零宽度即可。使用以下命令可以很好地呈现标题(请注意,结束括号和第一个单词\hspace{}之间没有空格:hspace

\caption[...]{\hspace{0pt}Unterschiedliche Abmessungen der EA-DOGM-LCDs.}

当然,可以定义一个宏来替换原始命令,例如:

\newcommand{\Caption}[2][]{\caption[#1]{\hspace{0pt}#2}}
\Caption{This is the caption text.}
\Caption[This goes into lof]{This still is the caption.}

相关内容