# Choose size of text inside a framed box and align it with the text width

I am using a framed box to put forward some texts. I have two problems:

• First, I would like to minimize the text size; as we can do for the legend of a figure: \captionsetup{width=0.95\textwidth, font=small}.

• Secondly, I have a problem with my alignment as regards the text. The framed boxes stay on the right at each page. I suspect a problem with all the others packages. That's why they are all here. Sorry for the long list.

Here is the code I use:

\documentclass{article}

% I put all packages to prevent any conflict

\PassOptionsToPackage{table,xcdraw}{xcolor}

\usepackage[utf8]{inputenc}
\usepackage[backend=bibtex,style=ieee,natbib=true, doi = false, url=false, arxiv=false]{biblatex}
\usepackage[autostyle=true]{csquotes}
\usepackage{microtype, mparhack, relsize}
\usepackage{amsmath}
\usepackage[bottom]{footmisc}
\usepackage{capt-of}
\usepackage{caption}
\captionsetup{width=0.95\textwidth, font=small}
\usepackage{subcaption}
\usepackage{float}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{minitoc}
\usepackage{enumitem}
\setlist[itemize]{label=\textbullet}
\usepackage{mathtools, nccmath}

% End of the long list

%Needed for the framed box:

\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\mdfdefinestyle{MyFrame}{%
linecolor=blue,
outerlinewidth=2pt,
roundcorner=20pt,
innertopmargin=\baselineskip,
innerbottommargin=\baselineskip,
innerrightmargin=20pt,
innerleftmargin=20pt,
backgroundcolor=gray!50!white}

\begin{document}
\lipsum[1-3]
\parbox{\textwidth}{\begin{mdframed}[style=MyFrame]
\lipsum[1]
$$f(x) = \sin(x)$$
\lipsum[2]
\end{mdframed}}
\end{document}

• I don't understand the first question. The second question, the boxes being a bit shifted to the right, is due to the paragraph indent. But i don't understand why you put the framed box iin a parbox? What do you want to achieve by that? – Johannes_B Dec 21 '18 at 8:36
• Package minitoc and this class are incompatible. See latex.org/forum/viewtopic.php?p=97529#p97529 – Johannes_B Dec 21 '18 at 8:38
• You can use \parbox{\dimexpr\textwidth-40pt} because of the margins of your framed box – koleygr Dec 22 '18 at 3:11