# fbox without additional v-space

it's a little bit related to Non-invasive replacement for \fbox? , but not really. think:

\documentclass[12pt]{article}
\begin{document}
\footnotesize
\begin{tabular}{lc}
a & 1\\
a & 1\\
\fbox{\fbox{b}} & 1\\
c & 1\\
c & 1\\
\end{tabular}
\end{document}


I do like that fbox leaves a little space on the inside (so that b is not touched by the lines), but then fbox "screws up" the vertical spacing in my paragraphs and tables. "screw up" is the wrong phrase, because adding vertical space to its line makes a lot of sense when one does not want text from one line to bleed into the other for some overlap.

but I use this fbox primarily to remind myself to fix something later on. so, I really want \fbox{\fbox{b}} (and fcolorbox) to take the same vertical space as b, even if its result protrudes into the line above and the line below. not always, but sometimes.

easy or hard? (if hard, please just say so and ignore question. this is an itch, not a problem.)

• I don't understand the question completely: You want to increase the horizontal separation between the frame and content only?
– user31729
Jan 16 '15 at 18:23

Considering that you want it only as a remainder and you'll delete the \fboxes later.... it is really ugly, but you can \smash the \fbox.

MWE:

\documentclass[12pt]{article}
\begin{document}
\footnotesize
\begin{tabular}{lc}
a & 1\\
a & 1\\
\smash{\fbox{\fbox{b}}} & 1\\
c & 1\\
c & 1\\
\end{tabular}
\end{document}


Output

You can, at least, redefine \foxsep to have it less ugly

\documentclass[12pt]{article}
\begin{document}
\renewcommand{\fboxsep}{1pt}
\footnotesize
\begin{tabular}{lc}
a & 1\\
a & 1\\
\smash{\fbox{\fbox{b}}} & 1\\
c & 1\\
c & 1\\
\end{tabular}
\end{document}


Output

• Perhaps something like \newcommand\DobBox[1]{\makebox[\dimexpr2\fboxsep-2\fboxrule\relax]{\smash{\fbox{\fbox{#1}}}}} and then simply \DobBox{b} so the frame won't interfere vertically nor horizontally? Jan 16 '15 at 18:32
• thx, gonzalo. it's a teeny bit off to the right, but even better for my intent. Jan 16 '15 at 21:55

The most important thing here is that you must define a personal command, which you can assign whatever meaning you want.

Here's an example, the \smash makes the colored box have zero vertical size, while \vphantom ensures the vertical size is the one of the contents.

\documentclass{article}
\usepackage{xcolor}

\newcommand{\remind}[1]{%
\leavevmode\vphantom{#1}%
\smash{\fboxsep=1pt\fcolorbox{red}{blue!20}{#1}}%
}

\begin{document}

\begin{tabular}{lc}
a & 1\\
a & 1\\
\remind{b} & 1\\
c & 1\\
c & 1\\
\end{tabular}

\end{document}


Here is another alternative using tcolorbox. The \remind box does not take additional vertical and horizontal space. Also, it is made a little bit transparent, i.e. overlapping text is not hidden completely:

\documentclass{article}
\usepackage{xcolor}
\usepackage[skins]{tcolorbox}

\newtcbox{\remind}{%
enhanced jigsaw,nobeforeafter,size=fbox,sharp corners,
shrink tight,
extrude by=3pt,
tcbox raise base,
colback=red!50,
colframe=red,
borderline={0.5pt}{-1pt}{red,opacity=0.75},
opacityframe=0.75,
opacityback=0.5,
}

\begin{document}

\begin{tabular}{lc}
a & 1\\
a & 1\\
\remind{b} & 1\\
c & 1\\
c & 1\\
\end{tabular}

Lorem ipsum dolor sit amet, \remind{consectetuer} adipiscing elit. Ut purus elit,
vestibulum ut, pla\remind{cer}at ac, adipiscing vitae, felis. Curabitur dictum gravida
mauris. \remind{Nam} arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu \remind{neque}. Pellentesque habitant morbi tristique senectus
et netus et malesuada fames ac turpis egestas.

\end{document}


• very cool, too. if one of these solutions could break across lines, I would be in heaven! ;-) Jan 17 '15 at 15:51
• @ivoWelch That is not possible with my solution. But I remember that there is a package which allows line markers which break over lines. I just cannot recall the name, but there are answers at TeX.SX which use it. I have not found them yet, but maybe you find the better search words ... Jan 17 '15 at 18:54