How can I make a vertical rule that extends to the edges of an fbox?

You can use \smash{\vrule}, but you have to specify the height and depth.

\documentclass{article}
\begin{document}
\sbox0{\fbox{some text more text}}%
\fbox{some text \smash{\vrule height\ht0 depth\dp0} more text}
\sbox0{\fbox{some text more deep text}}%
\fbox{some text \smash{\vrule height\ht0 depth\dp0} more deep text}
\sbox0{\fbox{some text more $\int$ tall text}}%
\fbox{some text \smash{\vrule height\ht0 depth\dp0} more $\int$ tall text}
\end{document}

demo


Or you could just use \struts and make all your \fboxes the same height.

\documentclass{standalone}
\begin{document}
\fbox{\strut some text}\hspace{-\fboxrule}\fbox{\strut some text}
\fbox{\strut some text}\hspace{-\fboxrule}\fbox{\strut more deep text}
\fbox{\strut some text}\hspace{-\fboxrule}\fbox{\strut more $\int$ tall text}
\end{document}

demo2


one way is to set \fboxsep to zero and than instead \vrule use accordingly set \rule:

\documentclass{minimal}
\setlength\fboxsep{0pt}
\newcommand\VR{\rule[-0.4\baselineskip]{0.4pt}{1.2\baselineskip} }

\begin{document}
\fbox{ some text \VR qjf more text }
\fbox{ some text \VR more deep text }
\fbox{ some text \VR more $\int$ tall text }
\end{document}

enter image description here


Looks like a tabular to me.

\documentclass{article} % see https://tex.stackexchange.com/q/42114/121799
\begin{document}
\begin{tabular}{|l|r|}
\hline
some text & more text\\
\hline
\end{tabular}

\begin{tabular}{|l|r|}
\hline
some text & more deep text\\
\hline
\end{tabular}

\begin{tabular}{|l|r|}
\hline
some text & more $\displaystyle\int$ tall text\\
\hline
\end{tabular}
\end{document}

enter image description here

Of course you can adjust the padding.

\documentclass{article} % see https://tex.stackexchange.com/q/42114/121799
% commands based on
\newcommand{\Tstrut}[1]{\rule{0pt}{#1}}       % "top" strut
\newcommand{\Bstrut}[1]{\rule[-#1]{0pt}{0pt}} % "bottom" strut
\newcommand{\TBstrut}[2]{\Tstrut{#1}\Bstrut{#2}}
\begin{document}
\begin{tabular}{|*{20}{c|}}
\hline
some text & more text\\
\hline
\end{tabular}

\begin{tabular}{|*{20}{c|}}
\hline
\TBstrut{2.5ex}{1.5ex}some text & more deep text\\
\hline
\end{tabular}

\begin{tabular}{|*{20}{c|}}
\hline
\TBstrut{4ex}{3ex}some text & more $\displaystyle\int$ tall text & and more \\[0.5ex]
\hline
\end{tabular}

\end{document}

enter image description here

You can make it a command and as long as you have less than 20 rules e.g.

\documentclass{article} 
\newcommand{\PartitionedBox}[2][20]{\begin{tabular}{|*{#1}{l|}} \hline #2\\ \hline \end{tabular}}
\begin{document}
 \PartitionedBox{123 & abc & xyz}
\end{document}

works. (Thanks to JouleV for suggesting to use the option.)

enter image description here

Tags:

Rules

Boxes

Fbox