\newsavebox, \usebox, and \savebox :
Code: Select all
% Create the holders we will need for our work
\newlength{\mytitleheight}
\newsavebox{\mytitletext}
% Create the reference text for measures
\savebox{\mytitletext}{%
\Large\bfseries This is our title%
}
\settoheight{\mytitleheight}{\usebox{\mytitletext}}
% Now creates the actual object in our document
\framebox[\textwidth][l]{%
\rule{5em}{\mytitleheight}%
\hspace{2mm}%
\usebox{\mytitletext}%
}
Doing the same with \newcommand:
Code: Select all
\newlength{\mahtitleheight}
\newcommand{\mahtitletext}{%
\Large\bfseries This is ahr title%
}
\settoheight{\mahtitleheight}{\mahtitletext}
\framebox[\textwidth][l]{%
\rule{5em}{\mahtitleheight}%
\hspace{2mm}%
\mahtitletext%
}