Text Formattingtext under \hrulefill

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
gosha
Posts: 16
Joined: Mon Nov 24, 2008 2:48 pm

text under \hrulefill

Post by gosha »

I need to prepare a "fill the blanks" test. I'm able to get the "blanks" with '\hrulefill' but I need to put a number under the line. The blanks need numbers because the answer has to be written on another page.
How do I do it?
Thanks in advance

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
latexforever
Posts: 120
Joined: Fri Nov 14, 2008 9:40 pm

text under \hrulefill

Post by latexforever »

Hello. The best solution I've found is using

Code: Select all

    \documentclass[10pt]{article}
    \usepackage{ifthen}

    \newboolean{Teachernotes} % false at start
%    \setboolean{Teachernotes}{true} % true if the output is the teacher's document, false if the output is the pupil's document; TO UNCOMMENT IF STUDENTS VERSION

    \newcounter{nb-holes}
    \setcounter{nb-holes}{1}
    

    \newcommand{\Hole}[1]{
    \ifthenelse{\boolean{Teachernotes}} % if the output is the teacher's document,
    {\textbf{#1}} % pupil-hidden words are in bold
    {\underline{\phantom{#1}} (\arabic{nb-holes})} % (else) at the place of the word (the pupil has to write down on his sheet), is a bar, to let him write. This bar has the word's size.
%        {$\underbrace{\underline{\phantom{#1}}}_{(\arabic{nb-holes})}$} % Does not work, actually.
    \addtocounter{nb-holes}{1} % nb-holes is incremented
    }
    


    \begin{document} %% TEST DOC
    Here is a \Hole{test}. The number of the test is \Hole{$\pi$}.
    \end{document}
If you find how to put the number under the bar, it would be very nice. It does not work for me, even with an underbrace (is there another solution, actually)?

I just programmed this now.
Post Reply