4

I defined a box to contain headers for each section in an instruction file. I have been using this personally defined box for quite a long time and it worked fine all the time. A MWE is as follows:

\ducumentclass{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{longfbox}

\newcommand*{\mylbox}[1]{\lfbox[border-style=double, border-width=3pt, width = \textwidth, padding=4pt]{\textbf{\centerline{\Large #1}}}}

\newcommand*{\mysbox}[1]{\centerline{\lfbox[border-radius = 1.5ex, border-width=2pt, padding=4pt, padding-left = 10em, padding-right = 10em]{\textbf{\large #1}}}}

\begin{document} \mylbox{General Information} \end{document}

However, when I made a few changes in the text (this can't be the reason), I got a lot of errors when I compile the file. Two examples of those error messages would be:

quote ! Undefined control sequence.\fbox@border@hcornerarc@ ...er -x}\fi @tempdimd \fbox@adjusty {@tempdimb ... l.71 \mylbox{General Information}

quote ! You can't use `\dimexpr' in restricted horizontal mode.\fbox@adjusty #1->\dimexpr \option {/fbox/@border-box-height} - #1\relax l.71 \mylbox{General Information}

A more complete list of error messages can be found here.

What is the problem? The only thing I did was that I updated many packages via MikTex like two days ago. Nothing else.

If you also need further details about a specific error, please let me know.

Lin Jing
  • 153

1 Answers1

4

Unfortunately, longfbox relies on a scratch register \@tempdimd that used to be allocated by pict2e, but no longer is.

You solve the issue by adding

\makeatletter
\newdimen\@tempdimd
\makeatother

in your document preamble. By the way, there is no need for \centerline.

\documentclass{article}
\usepackage{longfbox}

\makeatletter \newdimen@tempdimd \makeatother

\newcommand*{\mylbox}[1]{% \lfbox[ border-style=double, border-width=3pt, width = \dimexpr\textwidth-14pt, padding=4pt, ]{\hfill\bfseries\Large #1\hfill}% }

\begin{document}

\noindent\mylbox{General Information}

\end{document}

enter image description here

Note: thanks to campa who noted in comments that \@tempdimd used to exist in pict2e.

egreg
  • 1,121,712
  • Uhm, longfbox loads pict2e which does define \@tempdimd, so that cannot really be the issue, can it? – campa Nov 17 '20 at 10:43
  • Oh, wait, I have version 0.3b. In version 0.4b that has been renamed to \pIIe@tempdimd. That might be worth adding to your answer. – campa Nov 17 '20 at 10:47
  • @campa I'd not use the specific register of pict2e anyway. Better allocating a new one; the package maintainer can easily fix the issue. – egreg Nov 17 '20 at 10:51
  • Thanks a lot for your answer! I noticed that you made a few changes in the definition of mylbox: for width, it was changed from \textwidth to \dimexpr\textwidth - 14pt. Why is the latter one better? Could you please also explain a bit about the changes made in curly brackets? Thanks a lot! – Lin Jing Nov 17 '20 at 11:10
  • @LinJing With \textwidth you get an overfull line, because you have 7pt occupied at each side. Using \centerline is almost never good. – egreg Nov 17 '20 at 11:33
  • @egreg Thanks a lot. Using \bfseries instead of \textbf is simply to avoid so many curly brackets? I also defined another box that is shorter than this one. How to center it without using \centerline? The command is as follows: \newcommand*{\mysbox}[1]{\centerline{\lfbox[padding = 4pt, padding-left = 10em, padding-right = 10em]{\bfseries\large #1}}} – Lin Jing Nov 17 '20 at 12:23
  • @egreg sorry for asking so many elementary questions. Why did you add two % in the command? – Lin Jing Nov 17 '20 at 12:30
  • @egreg When I try to add the Advanced feature 'extra-split={1.5\baselineskip}' (Pg. 16 in the documentation) to a \begin{longfbox} ...\end{longfbox} environment, the error 'Package options Error: option "/fbox/extra-split": unknown option.' appears. What's /fbox got to do with the \begin{longfbox} ...\end{longfbox} environment? – RosesBouquet Jan 20 '23 at 13:25
  • @RosesBouquet I guess it's better to make a new question with the details. – egreg Jan 20 '23 at 15:02
  • @egreg - Thank you for the feedback. Will do ... as soon as I have a moment to assemble a MWE ... The longfbox package is dated 2015-12-05 ... I hope someone is still maintaining the package ;-) – RosesBouquet Jan 20 '23 at 18:37