# Set default width of \shadowbox to line, not column, width

When I insert a shadowbox using Lyx (Insert>Box>Drop Shadow) the width is specified as 100% of column width (1\columnwidth). This is the source code it generates:

\shadowbox{\begin{minipage}[t]{1\columnwidth}%
\end{minipage}}


The column width seems like a poor default choice since any indentation moves the shadowbox into the right-hand margin.* I'd like to make the line width (1\linewidth) the default width so boxes only extend up to the right-hand margin.

I tried redefining the \shadowbox command in my preamble but the parameter I'm trying to change is actually part of the \minipage inside the shadowbox and I haven't figured out how to access it.

I've also tried redefining the width of the frame based on this excerpt from the documentation:

The width of the frame is \fboxrule (the same as with \fbox). The width of the shadow is \shadowsize (default: 4pt).

by adding this line to my preamble:

\setlength{\fboxrule}{\linewidth}


It did not produce the results I expected (below). Is there a straightforward way to specify shadowboxes use line, not column, width by default?

Footnotes

* The shadowbox command was redefined in my preamble to ignore paragraph indenting

\let\oldshadowbox\shadowbox


But sometimes indentation is preferable such as when placing shadowboxes under list items

• Does \linewidth is OK for you? You just only to make it as a default when using the menu to insert the box? – Sigur Apr 17 '14 at 0:12
• Setting the \fboxrule does only change the thickness of the frame but not the width of the box itself. (Well, in same sense it did ;-)) – user31729 Apr 17 '14 at 0:14
• @Sigur Yes, I'd like to use \linewidth as the default when I insert a box via 'Insert>Box>Drop shadow' – patricktokeeffe Apr 17 '14 at 17:05
• @ChristianHupfer I can see now I didn't read the documentation literally enough. Good observation – patricktokeeffe Apr 17 '14 at 17:08

I'd suggest you to use \linegoal from the linegoal package (requires two compilations). Of course, you also need to take into account the padding of the box and the width of the shadow, so the width would be

-\fboxsep-\shadowsize+\linegoal


A complete example:

\documentclass{article}
\usepackage{fancybox}
\usepackage{linegoal}
\usepackage{showframe}

\begin{document}

\end{minipage}}

\end{minipage}}

\end{minipage}}

\end{document}


And you can make this the default behaviour using a command:

\documentclass{article}
\usepackage{fancybox}
\usepackage{linegoal}

#1
\end{minipage}}%
}

\begin{document}

\end{document}


• Ah I see why my attempts to redefine \shadowbox failed; thank you for the helpful answer @GonzaloMedina – patricktokeeffe Apr 17 '14 at 20:54
• Ultimately, what I want is to modify Lyx's behavior but I have marked your answer as accepted for its completeness. I do believe it carries the same caveat as my answer below though: users can not 'override' this method to set different widths for individual boxes. – patricktokeeffe Apr 17 '14 at 21:16

In LyX, follow the menu Edit > Box Settings... Here you can change the box width to measure \linewidth:

This should update your LaTeX code accordingly:

• Thanks @Werner this is my current procedure. I was hoping to make \linewidth the default – patricktokeeffe Apr 17 '14 at 17:10

@GonzaloMedina provides a valid and useful answer. I have found a simpler solution based on his second example code block. It will not work in all situations but handles my case:

% in the preamble:

Do realize this does not affect how Lyx inserts \shadowboxs, only how they are rendered in output. Consequently, users of this approach can no longer set widths on individual cases. (This is an issue with Lyx itself, not LaTeX.) Since the minipage with the shadowbox will be re-wrapped in a minipage of width 1\linewidth the width of text within the box is affected but box width is not.