你能否让某些行提前换行,并在常规缩进之外有一个悬挂缩进?

你能否让某些行提前换行,并在常规缩进之外有一个悬挂缩进?

我想修改此 LaTeX 代码,以便在换行到下一行时创建悬挂缩进效果。我希望它在文本区域的 75% 左右处中断并开始换行到新行,但缩进超过初始缩进?我还希望短行保留一个缩进,但不单独使用 \indent 标记,这样如果我要在这些行中添加更多内容,它们将自动按我想要的方式换行,我不需要添加任何其他内容。有办法做到这一点吗?

在此处输入图片描述

\documentclass[a4paper,9pt]{extarticle}
\usepackage{titlesec}
\setlist{noitemsep}
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}[\titlerule]
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}

% Begin document
\begin{document}

\section*{MY PROJECTS}
\noindent
\textbf{Engineering QTL's in Legume Species using CRISPR/Cas Technologies} \hfill London, Ontario, Canada\\ % Project name and location
\textit{Summer Research Assistant}
\hfill May 2019 | August 2019 \\
    \indent An example of a long line that's indented and that I want to be hanging on the subsequent lines. I want this to break at around 75\% of the textarea and start wrapping around to the new line but indented past the initial indent? Is there a way to do this?\\
    \indent An example of a short line that's indented.\\

\noindent
\textbf{Another Project} \hfill London, Ontario, Canada\\ % Project name and location
\textit{yadayada}
\hfill May 2019 | August 2019 \\
    \indent An example of a short line that's indented.\\
\end{document}

在此处输入图片描述

我在 Word 中制作了这个,以便展示我希望最终结果在 LaTeX 中的样子。

在此处输入图片描述

这可能吗?

答案1

使用tabularx

\documentclass[a4paper,9pt]{extarticle}

\usepackage[margin=2cm]{geometry}
\usepackage{tabularx}

\usepackage{titlesec}
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}[\titlerule]
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}



% Begin document
\begin{document}

\section*{MY PROJECTS}
   
\begin{tabularx}{\textwidth}{@{}>{\parindent=1em\hangindent=3em\hangafter=1}p{.75\textwidth}@{\extracolsep{\fill}}r@{}}
  \noindent\textbf{Engineering QTL's in Legume Species using CRISPR/Cas
  Technologies}
  & London, Ontario, Canada\\ % Project name and location
  \noindent\textit{Summer Research Assistant}
  & May 2019 | August 2019 \\
  An example of a long line that's indented and that I want to be
  hanging on the subsequent lines. I want this to break at around 75\%
  of the textarea and start wrapping around to the new line but
  indented past the initial indent? Is there a way to do this?\\ 
  An example of a short line that's indented.\\[1ex]
  \noindent\textbf{Another Project}
  & London, Ontario, Canada\\ % Project name and location 
  \noindent\textit{yadayada}
  & May 2019 | August 2019 \\
  An example of a short line that's indented.
\end{tabularx}

\end{document}

在此处输入图片描述

答案2

像这样?

平均能量损失

\documentclass[a4paper,9pt]{extarticle}
\usepackage[margin=2cm]{geometry}
\begin{document}
\section*{MY PROJECTS}
\paragraph{Engineering QTL's in Legume Species using CRISPR/Cas Technologies}\hfill London, Ontario, Canada\par 
\noindent\textit{Summer Research Assistant} \hfill May 2019 | August 2019\par
{\hsize.75\linewidth\parskip1ex\hangindent4em\parindent2em 
An example of a long line that's indented and that I want to be hanging on the subsequent lines. I want this to break at around 75\% of the textarea and start wrapping around to the new line but indented past the initial indent? Is there a way to do this?\par
\hangindent5em
An example of a short line that's indented.\par}
\paragraph{Another Project} \hfill London, Ontario, Canada\par
\noindent\textit{yadayada} \hfill May 2019 | August 2019\par
An example of a short line that's indented.
\end{document}

注意:我使用\par空行来代替只是为了指出段落的结尾。如果使用空行可以让代码更易读,请随意使用。结果不会改变。

答案3

这里是 paracol 方法。请注意,\hangindent在每一段中,必须重复使用它。

\documentclass[a4paper,9pt]{extarticle}
\usepackage{titlesec}
%\setlist{noitemsep}% ???
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}[\titlerule]
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}
\usepackage{paracol}
\setcolumnwidth{0.65\textwidth}
\usepackage{showframe}% alignment tool
% Begin document
\begin{document}

\section*{MY PROJECTS}
\begin{paracol}{2}
\sloppy% sop for narrow columns
\parindent=0pt
\textbf{Engineering QTL's in Legume Species using\linebreak[3] CRISPR/Cas Technologies}
\switchcolumn
London, Ontario, Canada % Project name and location
\switchcolumn*
\textit{Summer Research Assistant}
\switchcolumn
May 2019 | August 2019
\switchcolumn*
  \parindent=2em
  \hangindent=4em
An example of a long line that's indented and that I want to be hanging on the subsequent lines. I want this to break at around 75\% of the textarea and start wrapping around to the new line but indented past the initial indent? Is there a way to do this?

An example of a short line that's indented.
\switchcolumn[0]*[\medskip]% align both columns, but stay here (column 0)
\parindent=0pt
\textbf{Another Project}
\switchcolumn
London, Ontario, Canada% Project name and location
\switchcolumn*
\textit{yadayada}
\switchcolumn
May 2019 | August 2019
\switchcolumn*
  \parindent=2em
  \hangindent=4em
An example of a short line that's indented.
\end{paracol}
\end{document}

相关内容