1

I'm trying to build a date separator, which spans the entire width of the page and has a boxed date on the right. This is what I've written so far:

Test test test. 
\par\noindent\hfill\rule[3.4pt]{0.7\textwidth}{0.5pt}\fbox{\texttt{2021-04-08}}
Test test test. 

And this is the output: enter image description here

I'd like to do the following:

  • have \rule span the entire \textwidth, up to the box on the right
  • have \rule sit at half the height of the box (I guess that's almost done already)
  • start a new paragraph after the date (currently it continues in the same line)
luki
  • 1,796
ersbygre1
  • 185

1 Answers1

2

You can use This link to define another new command for your work. Like this:

\documentclass[12pt]{article}
\def\Vhrulefill{%
    \leavevmode\leaders\hrule height 0.7ex depth
    \dimexpr0.4pt-0.7ex\hfill\kern0pt%
}
\newcommand{\myDate}[1]{%
    \par\noindent\Vhrulefill\fbox{\texttt{#1}}\par
}
\begin{document}
Test test test. 
\myDate{2021-04-08}
Test test test. 
\end{document}

Output:

enter image description here