我想写一段这样的文字:
Text: This is a paragraph which is so long that it has a linebreak But the indent should be
set after \phantom{Text: }.
我该怎么做?在写普通文本时如何做到这一点?我该如何用图片标题做到这一点(使用多变的长度(例如,,Figure 1:
...,Figure 10:
等)?
答案1
注意:\caption
似乎比\blindtext
更好\lipsum
。此外,\hangindent
不会停止正常段落缩进。
\documentclass{article}
\usepackage{calc}
\usepackage{blindtext}
\usepackage{caption}
\newlength{\tempdima}
\begin{document}
\setlength{\hangindent}{\widthof{Test: }}
\noindent Test: \blindtext
\sbox0{Test: }%
\hangindent=\wd0
\noindent\box0\blindtext
\settowidth{\tempdima}{Test: }
\hangindent=\tempdima
\noindent Test: \blindtext
\begin{figure}[htp]
\captionsetup{format=hang}
\caption{\blindtext}
\end{figure}
\end{document}
答案2
对于普通文本,我会使用描述。如果上面的垂直空间或“文本”的粗体字体让您感到困扰,可以更改这些。
正如 John Kormylo 所指出的:为了使标题表现出这样的效果,该caption
包提供了一种悬挂格式。
\documentclass{article}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[format=hang]{caption}
\begin{document}
\section{Test}
\lipsum[1]
\begin{description}
\item[Text] \lipsum[2]
\end{description}
\begin{figure}[htbp]
\centering
\includegraphics[width=.5\textwidth]{example-image}
\caption{long caption text that spans more than one line long caption text that spans more than one line long caption text that spans more than one line}
\end{figure}
\end{document}
答案3
您可以使用该hanging
包,它是用于纯 TeX 构造的 LaTeX 接口\hangindent=...\hangafter=...
。
该包定义了一个\hangingpara
命令和一个hangingparas
环境。演示:
\documentclass{book}
\usepackage{enumitem}
\usepackage{calc}
\usepackage{hanging}
\usepackage{lipsum}
\newlength{\myhangindent}
\begin{document}
\settowidth{\myhangindent}{Text: }
\hangpara{\myhangindent}{1}%
Text: This is a paragraph which is so long that it has a linebreak at its end. But the indent
should be set after \phantom(Text: ).
\begin{hangparas}{\myhangindent}{1}%
\lipsum[10-12]
\end{hangparas}
\end{document}