2

How can we write words on a border of \fbox in LaTeX like this

enter image description here

Hope image is clear.

1
  • 3
    Welcome to TeX-SE! This can be done e.g. with the decorations.text library of TikZ. – user121799 Apr 2 '19 at 2:25
4

This is to give you a start. There are many ways in which you can adjust things, as explained in section 50.6 Text Decorations of the pgfmanual.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
\node[text width=1.9cm,inner sep=3pt] (T) {3/3/30};
\path[decorate,decoration={text along path,
text={|\fontsize{6}{6}\selectfont\sffamily|Something about ducks, marmots,
koalas and groundhogs}}] (T.south west) rectangle (T.north east);
\end{tikzpicture}
\end{document}

enter image description here

Here is another example.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
\node[text width=1.75cm,inner sep=3pt] (T) {3/3/30};
\path[decorate,decoration={text along path,
text={|\fontsize{6}{6}\selectfont\sffamily|Something about ducks, marmots,
koalas and groundhogs}}] ([yshift=0.1ex]T.south west) -- ([yshift=-0.1ex]T.north west)
([xshift=-0.3em]T.north west) -- ([xshift=0.3em]T.north east)
([yshift=-0.1ex]T.north east) -- ([yshift=0.1ex]T.south east)
([xshift=0.3em]T.south east) -- ([xshift=-0.3em]T.south west);
\end{tikzpicture}
\end{document}

enter image description here

2
  • Can you modify the code so that the spaces at corners are not there. i.e. no space at corner of "somet" and "hing". Thanks in advance. – user184854 Apr 2 '19 at 6:54
  • @user184854 I added an example of that type, – user121799 Apr 2 '19 at 13:02

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.