2

I am creating a test using the exam package. I do have some fillin questions using the \fillin command.

I know that that I can specify the fillin lines length with an absoulte value using \fillin[correct answer][5cm], but I would like the line to stretch until the end of the line.

Is that possible?

1
  • \fillin[{\color{red}$25a^2+70a+49$}][\linewidth] Commented Dec 18, 2022 at 19:13

1 Answer 1

5

The fillin command seems to accept only absolute length values. However, you can leave out the fillin and put a default horizontal line with \hrulefill. It is possible to add something after the line, in the MWE below there is a space and a period (\ .).

A disadvantage is that the correct answer is not specified, which means that it is not shown in answer mode. A solution is to combine fillin with a horizontal line, however the baseline differs slightly. Using the package xhfill you can adjust the baseline. Results using different viewers, different zoom levels, or in print are not guaranteed to be consistent.

MWE:

\documentclass[answers]{exam}
\usepackage{xhfill}
\begin{document}
\begin{questions}
\question The magic word is \hrulefill\ .
\question Where is the baseline? \fillin[low]\hrulefill
\question The normal word is \fillin[correct answer][5cm]\xrfill[-1pt]{0.2mm}
\end{questions}
\end{document}

Result:

enter image description here

2
  • Too bad it doesn't work out of the box, but your alternative is great, too. Thanks. One question: What does MWE stand for?
    – mat
    Commented Jan 27, 2017 at 8:42
  • MWE stands for Minimal Working Example, which is the smallest complete document that illustrates a problem or a solution, or a starting point for a document where you want to add something. Adding this to a post makes it much easier for others to reproduce a problem or a solution. See meta.tex.stackexchange.com/questions/228/…
    – Marijn
    Commented Jan 27, 2017 at 9:54

You must log in to answer this question.

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