2

I want to have the indentation of a description environment

\documentclass[
10pt, 
a4paper, 
titlepage
]{scrartcl}

\usepackage[
nochapters,        
beramono, 
eulermath,
pdfspacing, 
dottedtoc 
]{classicthesis} 
\usepackage[utf8]{inputenc} 
\usepackage{enumitem} 

\begin{document}
\begin{description}
\item[Question 1:]Cumque repudiandae molestiae impedit laboriosam ut     
    enim. Velit magni qui placeat aliquam. Culpa aut tempora illo ipsa ut  
    qui nemo nostrum. Sed voluptas iure voluptates. Quos assumenda dolore  
    non qui est beatae mollitia aut.
\end{description}
\end{document}

which turns out quite nicely:

enter image description here

Is it possible to have this indentation effect without using the description environment and by using a normal text-style, not the all caps monospace font?

EDIT: I'm open to switching to another environment (as long as $math$ is still supported), although I'd prefer to "just have it hanging".

  • Welcome to TeX.SX! Please make your code compilable. Do you want to switch to another list environment or do you really just want that hanging? – TeXnician Feb 19 '17 at 14:50
  • I don't want another environment, but really "just that hanging". How do I know if my code is compilable? I did a quick-search on meta but couldn't find anything... – Narusan Feb 19 '17 at 14:54
  • 1
    The code you posted doesn't generate the screenshot you posted. Is the difference intentional/accidental/incidental? Please advise. – Mico Feb 19 '17 at 15:13
  • 1
    It was accidental, I updated my question. – Narusan Feb 19 '17 at 15:48
2

A quick and dirty solution would be an own \hangfrom version (LaTeX provides such functionality itself, but it's not userfriendly). But of course that's not a real solution for huge documents.

Note, formatting is up to you.

question

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand*{\hangfrom}[1]{\setbox\@tempboxa\hbox{{#1}}\hangindent \wd\@tempboxa\noindent\box\@tempboxa}
\makeatother

\begin{document}
\hangfrom{\makebox[1em]{Question 1:}}\hskip3emCumque repudiandae molestiae impedit laboriosam ut     
    enim. Velit magni qui placeat aliquam. Culpa aut tempora illo ipsa ut  
    qui nemo nostrum. Sed voluptas iure voluptates. Quos assumenda dolore  
    non qui est beatae mollitia aut.
\end{document}

Update: Using a list, you could try enumitem. If you want those enumerate settings to be global, use \setlist[enumerate]{options} with the options you want in the preamble. You can of course just try which options fit best for you, it's a matter of taste.

Huge advantage of this solution: It also steps the counter (if you're talking about more than one question).

another question

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem}

\begin{document}    
\begin{enumerate}[label=\textbf{\emph{Question \arabic*}:},leftmargin=*,itemindent=3em]
    \item Cumque repudiandae molestiae impedit laboriosam ut     
    enim. Velit magni qui placeat aliquam. Culpa aut tempora illo ipsa ut  
    qui nemo nostrum. Sed voluptas iure voluptates. Quos assumenda dolore  
    non qui est beatae mollitia aut.
\end{enumerate}
\end{document}
  • Great to know. It is quite dirty though, is there another way to do this? I'm open to use list too, I want to use /textbf{} and /emph{} with the "Question 1:" part though and I'm not sure if that works. – Narusan Feb 19 '17 at 15:10
  • Great! This is exactly what I needed. Thanks a lot. – Narusan Feb 19 '17 at 15:22
  • For me, itemindent=3em worked best... – Narusan Feb 19 '17 at 15:48
  • @Narusan That's a question of personal taste and of course the font-face, but I just wanted to provide a starter, so it was just that you see how you are enabled to adjust it. – TeXnician Feb 19 '17 at 16:19
  • Yeah, I meant that itemindent=3em creates the exact same indentation as the description environment. Sorry for that – Narusan Feb 19 '17 at 16:20
3

You can easily adapt the description environment (also globally) with enumitem:

\documentclass{article}
\usepackage{amsmath,enumitem}

\begin{document}
\begin{description}[font=\normalfont]
\item[Question 1:]Cumque repudiandae molestiae impedit laboriosam ut
    enim. Velit magni qui placeat aliquam. Culpa aut tempora illo ipsa ut
    qui nemo nostrum. Sed voluptas iure voluptates. Quos assumenda dolore
    non qui est beatae mollitia aut.
\end{description}
\end{document}
  • Thank you very much. I can't up vote your answer because my reputation is too low. For the future, maybe include a picture of the compiled text... – Narusan Feb 19 '17 at 15:22
1

You can do it with the hanging package, which adds no vertical spacing w.r.t. the surrounding text. The hangparas defines hanging indentation for all paragraphs included in the environment. The first argument of the environment is the hanging width, the second is the number of lines untouched if it is positive, the number of lines touched if it is negative. Similarly, if the indentation is negative, it is an indentation on the right side. Here are four examples with 2 lines non-indented first (Questions 1 and 2), the following lines being indented, and 2 lines indented, the following lines being non-indented (Question 3 and 4):

\documentclass[
10pt,
a4paper,
titlepage
]{scrartcl}

\usepackage[
nochapters,
beramono,
eulermath,
pdfspacing,
dottedtoc
]{classicthesis}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{hanging}

\begin{document}

Some text some more text still some more text. Some text some more text still some more text.

\begin{hangparas}{2.5em}{2}
Question 1: Cumque repudiandae molestiae impedit laboriosam ut
    enim. Velit magni qui placeat aliquam. Culpa aut tempora illo ipsa ut
    qui nemo nostrum. Sed voluptas iure voluptates. Quos assumenda dolore
    non qui est beatae mollitia aut

Question 2: Cumque repudiandae molestiae impedit laboriosam ut
    enim. Velit magni qui placeat aliquam. Culpa aut tempora illo ipsa ut
    qui nemo nostrum. Sed voluptas iure voluptates. Quos assumenda dolore
    non qui est beatae mollitia aut
\end{hangparas}


\begin{hangparas}{2.5em}{-2}
Question 3: Cumque repudiandae molestiae impedit laboriosam ut
    enim. Velit magni qui placeat aliquam. Culpa aut tempora illo ipsa ut
    qui nemo nostrum. Sed voluptas iure voluptates. Quos assumenda dolore
    non qui est beatae mollitia aut
\end{hangparas}

\begin{hangparas}{-2.5em}{-2}
Question 4: Cumque repudiandae molestiae impedit laboriosam ut
    enim. Velit magni qui placeat aliquam. Culpa aut tempora illo ipsa ut
    qui nemo nostrum. Sed voluptas iure voluptates. Quos assumenda dolore
    non qui est beatae mollitia aut
\end{hangparas}

\end{document} 

enter image description here

  • I explain you can choose the number of non-indented lines and decided to make a demonstration with 2. But of course, for what you want, you just have to use 1 as the second argument. – Bernard Feb 19 '17 at 17:30
  • Sorry, should have read more carefully. Silly me! – Narusan Feb 19 '17 at 17:40
  • You're welcome! I didn't initially mention I used for demo purposes a value different from yours. – Bernard Feb 19 '17 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.