TransWikia.com

How to force first paragraph indentation in exam class

TeX - LaTeX Asked by yungszen on June 22, 2021

I’m using the exam.cls and after question, i have some description before going into part.

How do i add an indent for the first line of the question?
I’ve tried indentfirst package, hspace{}, itemindent, parindent and these didnt work.

enter image description here

documentclass[addpoints, a4paper, 12pt]{exam}
usepackage{setspace, amsmath, pdfpages, mathtools}
usepackage{times}
pagestyle{headandfoot}
setstretch{1.3} 

setlength{rightpointsmargin}{2.5cm}
cfoot[thepage]{thepage} % page numbering
qformat  % Format for question
{
    textbf{QUESTION thequestion{} (pointsofquestion{thequestion} marks)} 
    hfill
    vrule depth 1.7em width 0pt
}

pointsdroppedatright % enable points at the right margin
marksnotpoints
marginpointname{ points}


% To adjust questions margins
renewcommand{questionshook}{%
  setlength{leftmargin}{0pt}%
    setlength{labelwidth}{-labelsep}%
  setlength{itemsep}{1em}
}

% To adjust parts margins
renewcommand{partshook}{%
  setlength{leftmargin}{1.4cm}%
  setlength{labelsep}{1cm}
  setlength{labelwidth}{0cm}%
  setlength{itemsep}{1em}

}

begin{document}

begin{questions}

question
bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla 

begin{parts}

    part[5]
    bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla 
    
    droppoints 
    
    part[4]
    bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla 
    
    droppoints 

end{parts}

end{questions}

end{document}

Thanks in advance.

One Answer

Below I patch question (defined within the environment questions) by appending an hspace*{1.5em}ignorespaces to it. That inserts the starting space.

enter image description here

documentclass[addpoints, a4paper, 12pt]{exam}

setlength{rightpointsmargin}{2.5cm}
cfoot[thepage]{thepage} % page numbering
qformat  % Format for question
{%
    textbf{QUESTION thequestion{} (pointsofquestion{thequestion} marks)} 
    hfill
    vrule depth 1.7em width 0pt
}

pointsdroppedatright % enable points at the right margin
marksnotpoints
marginpointname{ points}


% To adjust questions margins
renewcommand{questionshook}{%
  setlength{leftmargin}{0pt}%
    setlength{labelwidth}{-labelsep}%
  setlength{itemsep}{1em}%
  letoldquestionquestion% Copy question into oldquestion
  renewcommand{question}{%
    oldquestion% Default question style
    hspace*{1.5em}ignorespaces% Insert paragraph indent/space
  }%
}

% To adjust parts margins
renewcommand{partshook}{%
  setlength{leftmargin}{1.4cm}%
  setlength{labelsep}{1cm}
  setlength{labelwidth}{0cm}%
  setlength{itemsep}{1em}

}

begin{document}

begin{questions}

  question
  bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla 

  begin{parts}

    part[5]
    bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla 
    
    droppoints 
    
    part[4]
    bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla bla bla bla bla blab bla 
    
    droppoints 

  end{parts}

end{questions}

end{document}

Correct answer by Werner on June 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP