[texhax] TeX underline & \hfill question
Hubert Lam
hubert at lamfamily.info
Sun Dec 4 09:38:20 CET 2011
Hi Amber K
I nicked it off http://melusine.eu.org/syracuse/latex/exemples/desousa/definition.tex and modified it to my needs. Basically it is pstricks + calc + pifont packages with some very smart calculations with lengths.
\usepackage{pifont}
\usepackage{calc}
\usepackage[dvipsnames]{pstricks}
\newlength{\margedef}
\newlength{\marge}
\setlength{\marge}{0.75cm}
\newcounter{example}
\newsavebox{\examplebox}
\newcommand{\exampleboxtext}{\ding{46} \textsf{Example \theexample}}
\newlength{\exampletextlength}
\setlength{\exampletextlength}{\widthof{\textbf{\exampleboxtext}}+\widthof{\textsf{\textbf{8}}}+1cm}
\newenvironment{boxexample}{
\par\noindent % No indentation
\refstepcounter{example} % Counter for this environment
\begin{lrbox}{\examplebox} % Name of box to contain text
\begin{minipage}{0.95\linewidth-0.5cm}
}
{
\end{minipage}
\end{lrbox}%
\rput[tl](0,0){ % Choose colours of framebox
\psframebox[fillstyle=solid,fillcolor=LimeGreen!30,framearc=0.5,framesep=10pt,linecolor=Green]{%
\usebox{\examplebox}
}
}
\rput[l](1cm,0){ % Patch white line
\psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\exampletextlength,0)%
}%
\rput[l](1cm,0.5ex){ % Place text
\textcolor{Green}{\textbf{\exampleboxtext}}%
}
\par
\setlength{\margedef}{\ht\examplebox+\dp\examplebox+\marge}
\vspace{\margedef}
}
\begin{document}
\begin{boxexample}
Some examples within the box.
\end{boxexample}
\end{document}
From: Amber K [mailto:skubesch at yahoo.com]
Sent: Sunday, December 04, 2011 7:15 PM
To: Hubert Lam
Subject: RE: [texhax] TeX underline & \hfill question
Thank you so much for this information! The box with the rounded edges looks amazing; what code did you use to create it?
-Amber
--- On Sun, 12/4/11, Hubert Lam <hubert at lamfamily.info<mailto:hubert at lamfamily.info>> wrote:
From: Hubert Lam <hubert at lamfamily.info<mailto:hubert at lamfamily.info>>
Subject: RE: [texhax] TeX underline & \hfill question
To: "Amber K" <skubesch at yahoo.com<mailto:skubesch at yahoo.com>>, "texhax at tug.org<mailto:texhax at tug.org>" <texhax at tug.org<mailto:texhax at tug.org>>
Date: Sunday, December 4, 2011, 7:35 AM
By the way, here is the result:
[cid:image001.png at 01CCB2BB.FEA27570]
Also amend the \vspace[3ex] to your liking depending on how large your handwriting may be. This is to adjust the vertical height provided for the fill in lines.
From: Hubert Lam
Sent: Sunday, December 04, 2011 6:29 PM
To: 'Amber K'; texhax at tug.org<mailto:texhax at tug.org>
Subject: RE: [texhax] TeX underline & \hfill question
Hi Amber K,
Are you trying to create lines for people to handwrite/fill in (cloze)?
If so here’s my implementation.
\documentclass{article}
\usepackage{calc}
\newcommand{\Cloze}[1]{\begin{minipage}[b]{\widthof{\Huge \textbf{#1}}} \vspace{3ex} \dotfill \end{minipage}}
% creates a minipage of the width of the required text which \dotfill can fill up
\begin{document}
A \textbf{relation} is a \Cloze{rule} that maps \Cloze{elements} from the \Cloze{domain} to the \Cloze{range}.
\end{document}
This will create dotted lines with variable length \dotfill s. The package calc does the magic in calculating the hspace required.
Hubert
From: texhax-bounces at tug.org</mc/compose?to=texhax-bounces at tug.org> [mailto:texhax-bounces at tug.org]</mc/compose?to=%5bmailto:texhax-bounces at tug.org%5d> On Behalf Of Amber K
Sent: Sunday, December 04, 2011 5:40 PM
To: support at tug.org</mc/compose?to=support at tug.org>
Subject: [texhax] TeX underline & \hfill question
When I create lesson plans, I like to make handouts with lines that fill the page as well a solutions keys where I put text on the lines. I've been manually adjusting the widtch value in inches one line at a time until they line up, and I'm really hoping there is an easier way.
Right now, if the handout looks like:
Conclusion: \hrulefill
I am typing this for the key:
Conclusion: \underline{\makebox[4.94in][s]{\color{red}{Answers will vary but should be based on evidence collected}{\hfill}}}
Where the 4.94in part was the value I needed to manually adjust. When I want to have everything underlined, I found a suggestion online to do something like this:
\underline{\makebox[5.7in][s]{Choice 2: \color{red}{Students should select a second choice from one of the five options below. They }{\hfill}}}
This works extremely well for those cases, but I'm hoping there is way to do something like that without having to either have everything underlined or nothing at all. I searched for a way to remove underlining from part of the command (like \textnormal) but I haven't found anything to work for removing underlining. Any suggestion would be very greatly appreciated.
Thanks,
Amber
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20111204/dbfb171d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 36398 bytes
Desc: image001.png
URL: <http://tug.org/pipermail/texhax/attachments/20111204/dbfb171d/attachment-0001.png>
More information about the texhax
mailing list