1

I want to modify this LaTeX code to create a hanging indent effect when the line wraps to the next line. 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? I also want short lines to remain having one indent, but to not use the \indent tag alone so that if I was to add more to those lines they would automatically wrap how I'd like and I wouldn't need to add anything else. Is there a way to do this?

enter image description here

\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}

enter image description here

I've made this in Word to kinda show how I want the end results to look like in LaTeX.

enter image description here

Is this possible?

1
  • 1
    slightly related but never end a paragraph with \\ (you should never need to use \indent as indentation is added automatically at the start of paragraphs. Dec 30, 2023 at 17:16

3 Answers 3

1

Using 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}

enter image description here

0

Like this?

MWE

\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}

Note: I used \par instead of blank lines just to point where should be the ends of paragraph. Feel free of use blank lines if that make the code more readable for you. The result will not change.

0

Here ia a paracol approach. Note that \hangindent has to be repeated every paragraph where it is used.

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .