图片标题包含大量下划线

图片标题包含大量下划线

我正在使用以下代码生成如附件中的文档。问题是 latex 没有以标题中的新行开头。可能是因为 _。有什么办法可以解决这个问题吗?

多谢!!

 \documentclass[obeyspaces,spaces,a4paper,fleqn]{report}
 \usepackage{caption}

 \captionsetup{aboveskip=6pt, format = hang, justification = raggedright, singlelinecheck = false, labelfont=bf} 

 \begin{document}
 \begin{figure}[H]

 \setlength{\unitlength}{1cm}

 \begin{picture}(16.5,12.3773)
 \put(0,0){\includegraphics[scale=0.25798]{io_dme_PDFs/00000000005_ADC.pdf}}
 \end{picture}

 \caption{\small io\_dme/IO\_DME/HardwareInterface/HWI/ADC\_io\_dme/IO\_DME/HardwareInterface/MappingToHardware/DIG\_OUT/DS2211\_02\_07\_DIG[0\textbar 1]\_io\_dme/IO\_DME/HardwareInterface/MappingToHardware/DIG\_OUT/DS2211\_02\_07\_DIG[0\textbar 1]}
 \label{iodme/IODME/HardwareInterface/HWI/ADC}

 \end{figure}
 \end{document}

标题有很多_

答案1

这对我来说编译得很好

\documentclass[obeyspaces,spaces,a4paper,fleqn]{report}
 \usepackage{caption}

 \captionsetup{aboveskip=6pt, format = hang, justification = raggedright, singlelinecheck = false, labelfont=bf} 

\usepackage{url}

 \begin{document}
 \begin{figure}

 \caption{\protect\path{io_dme/IO_DME/HardwareInterface/HWI/ADC_io_dme/IO_DME/HardwareInterface/MappingToHardware/DIG_OUT/DS2211_02_07_DIG[0|1]_io_dme/IO_DME/HardwareInterface/MappingToHardware/DIG_OUT/DS2211_02_07_DIG[0|1]}}
 \label{iodme/IODME/HardwareInterface/HWI/ADC}

 \end{figure}
\end{document}

在此处输入图片描述

答案2

没有人能读懂这样的标题。你可以手工剪切它:

 \caption{\small io\_dme/IO\_DME/HardwareInterface/HWI/ADC\_io\_dme/IO\_DME/\\HardwareInterface/MappingToHardware/DIG\_OUT/\\DS2211\_02\_07\_DIG[0\textbar 1]\_io\_dme/IO\_DME/HardwareInterface/\\MappingToHardware/DIG\_OUT/DS2211\_02\_07\_DIG[0\textbar 1]}

但最好还是做成超链接。在此处输入图片描述

答案3

据我所知,LaTeX 不会在“/”字符处自动中断。但是,您可以插入\allowbreak命令(惊喜!)让 LaTeX 在指定点中断。例如,

\caption[short caption]{\small io\_dme/\allowbreak{}IO\_DME/\allowbreak{}HardwareInterface/\allowbreak{}HWI/\allowbreak{}ADC\_io\_dme/\allowbreak{}IO\_DME/\allowbreak{}HardwareInterface/\allowbreak{}MappingToHardware/\allowbreak{}DIG\_OUT/\allowbreak{}DS2211\_02\_07\_DIG[0\textbar 1]\_io\_dme/\allowbreak{}IO\_DME/\allowbreak{}HardwareInterface/\allowbreak{}MappingToHardware/\allowbreak{}DIG\_OUT/\allowbreak{}DS2211\_02\_07\_DIG[0\textbar 1]}

将告诉 LaTeX 在适当的位置自动断开文本。

请注意,出于某种原因,您也需要指定参数[short caption],否则 LaTeX 会抱怨。我不确定为什么会这样。

相关内容