I'm a newbie to LaTeX as of a couple days ago, and was delighted to hear of an exam package that would ease my pain. However, I've worked out that the exam paper I am trying to emulate definitely did not use the exam package based on things like how the marks are done and where question sub-parts go.

So I want to emulate the question lines in it - I tried looking in the exam.cls source code but it is very esoteric to me as a beginner. I've been trying to use \line(1, 0){some number} but that can easily go past the right margin - which I don't want it to do - i.e. I want a line which I can start at an indented or tabbed position and it will stop at the right margin.

See below for an image of how this looks.

Exam Question

1 Answer 1


You can copy the code for \fillwithlines straight out of exam.cls, and it will work inside of an enumerate environment:


%                            \fillwithlines

% \fillwithlines takes one argument, which is either a length or \fill
% or \stretch{number}, and it fills that much vertical space with
% horizontal lines that run the length of the current line.  That is,
% they extend from the current left margin (which depends on whether
% we're in a question, part, subpart, or subsubpart) to the right
% margin.
% The distance between the lines is \linefillheight, whose default value
% is set with the command
% \setlength\linefillheight{.25in}
% This value can be changed by giving a new \setlength command.
% The thickness of the lines is \linefillthickness, whose default value
% is set with the command
% \setlength\linefillthickness{.1pt}
% This value can be changed by giving a new \setlength command.


    \leaders\hrule height \linefillthickness \hfill\kern\z@}

  \hrule height \z@
  \setbox0=\hbox to \hsize{\hskip \@totalleftmargin
          \vrule height \linefillheight depth \z@ width \z@
  % We use \cleaders (rather than \leaders) so that a given
  % vertical space will always produce the same number of lines
  % no matter where on the page it happens to start:
  \cleaders \copy0 \vskip #1 \hbox{}%


\item Let $y = (3x^{2} - 5x)^{5}$.  Find $\frac{dy}{dx}$.

\item Let $f(x) = x \e^{3x}$.  Evaluate $f'(0)$.

  • Ok cool - so I will put that in a custom .cls file in the same directory, something like "examlines.cls" - I've taken a brief look at how to 'import' that but haven't seen how to do it. Is it something like \usepackage{examlines}?
    – nebffa
    Jun 4, 2013 at 8:32
  • 1
    @nebffs: Yes, \usepackage{examlines} is exactly right, but you also need to remove the lines \makeatletter and \makeatother if you've put that code into a style file. Jun 5, 2013 at 1:22
  • Sorry about being away for so long - I hope I haven't left it too long. Thanks for your answer - however I specifically don't want to enumerate the questions as that gives me a formatting I don't like - is there a way to do this not in an enumerate environment?
    – nebffa
    Jun 9, 2013 at 10:37
  • Hey Phil - I've been able to work it out. Instead of using \fillwithlines I can instead use multiple \linefill commands coupled with a custom \tab command each line to create multiple lines (e.g. \tab \linefill times 4 to create 4 lines). Your answer was close and gave me lots of help so I'm going to accept it - thanks!!!!
    – nebffa
    Jun 10, 2013 at 2:08
  • @nebffa: Glad to hear it helped. Jun 10, 2013 at 5:30

You must log in to answer this question.

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