2

Here is a starting code for a template to write sheets of exercises.

\documentclass[12pt]{article}
\usepackage{xhfill}   % https://tex.stackexchange.com/a/155960/6880
\usepackage[showframe]{geometry}

\begin{document}

START

\setlength{\fboxrule}{0.2ex}
\framebox{Ex.1}\xrfill[0.4ex]{0.25ex}

\end{document}

I would like to add materials above and below the filling rule like in the following picture. How can I achieve this ?

enter image description here

1

You can set a zero-width box with content raised/lowered into position:

enter image description here

\documentclass{article}

\usepackage{xhfill}
\usepackage[showframe]{geometry}

\begin{document}

START

\setlength{\fboxrule}{0.2ex}%
\framebox{Ex.1}\xrfill[0.4ex]{0.25ex}%
\makebox[0pt][r]{\raisebox{.5\baselineskip}[0pt][0pt]{\scshape above}}%
\makebox[0pt][r]{\raisebox{-.6\baselineskip}[0pt][0pt]{\scshape below}}%

\end{document}

The raised/lowered text is set with 0pt height/depth so it doesn't affect the line spacing for surrounding content.

  • Thanks. I have to learn to play more seriously with boxes... – projetmbc Nov 13 '17 at 23:27
1

You can use stackengine's top and bottom lapping macros. Here \tllap is a top-left lap, and \bllap is a bottom-left lap. The optional argument provides the baseline skip of the lap. The % at line end is necessary to avoid stray spaces before or between laps.

\documentclass[12pt]{article}
\usepackage{xhfill}   % https://tex.stackexchange.com/a/155960/6880
\usepackage[showframe]{geometry}
\usepackage{stackengine}
\begin{document}

START

\setlength{\fboxrule}{0.2ex}
\framebox{Ex.1}\xrfill[0.4ex]{0.25ex}%
\tllap[6pt]{Here}%
\bllap[9pt]{and There}

\end{document}

enter image description here

  • Shorter to write. Thanks for this short version. – projetmbc Nov 13 '17 at 23:30

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.