1

Framebox need to increase 350pt width if box exceed to \textwidth(currently it as 300pt) in the above defined environments, I tried lot of ways not succeed, could you please try to fix my issues? Note: Solution needed existing macros.

\documentclass[draft]{book}
\usepackage{color,alltt,lipsum}
\overfullrule0pt

\setlength\textwidth{300bp}% \definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}

\usepackage{framed} \makeatletter \newbox\kframebox% \newdimen\kframeboxwd%

\newenvironment{kframe}{% \fboxsep3.5pt% \def\at@end@of@kframe{}% \ifinner\ifhmode% \def\at@end@of@kframe{\end{minipage}}% \begin{minipage}{\columnwidth}% \fi\fi% \def\FrameCommand##1{\hskip@totalleftmargin %\hskip-\fboxsep \colorbox{shadecolor}{##1}%\hskip-\fboxsep % There is no \@totalrightmargin, so: \hskip-\linewidth \hskip-@totalleftmargin \hskip\columnwidth}% \MakeFramed {\advance\hsize-\width @totalleftmargin\z@ \linewidth\hsize @setminipage} }% {\par\unskip\endMakeFramed%\vskip.5pt \at@end@of@kframe% }

\newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}% \newcommand{\hlstr}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}% \newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}% \newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}% \newcommand{\hlstd}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}% \newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}% \newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}% \newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}% \newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}% \let\hlipl\hlkwb

%\newenvironment{kframelong}{\bgroup\par% %\hsize428bp\fboxsep3.5pt%% % \def\at@end@of@kframe{}% % \ifinner\ifhmode% % \def\at@end@of@kframe{\end{minipage}}% % \begin{minipage}{\columnwidth}% % \fi\fi% % \def\FrameCommand##1{\hskip@totalleftmargin %\hskip-\fboxsep % \colorbox{shadecolor}{##1}%\hskip-\fboxsep % \hskip-\linewidth \hskip-@totalleftmargin \hskip\columnwidth}% % \MakeFramed {\advance\hsize-\width % @totalleftmargin\z@ \linewidth\hsize % @setminipage} % }% % {\par\unskip\endMakeFramed%\vskip.5pt % \at@end@of@kframe% % \egroup\par% % % % }

\makeatother \begin{document}

\lipsum[5]

\definecolor{shadecolor}{cmyk}{0,0.05,0.14,0}\color{fgcolor} \begin{kframe} \begin{alltt} \textcolor{blue}{17}\textcolor{red}{:}\textcolor{blue}{58} \end{alltt} \begin{verbatim}

[1] 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

[23] 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

\end{verbatim} \end{kframe}

\lipsum[5]

\begin{kframe} \begin{alltt} \textcolor{blue}{17}\textcolor{red}{:}\textcolor{blue}{58} \end{alltt} \begin{verbatim}

[1] 17 18 19 20 21 22 23 24 25

[23] 39 40 41 42 43 44 45

\end{verbatim} \end{kframe}

\end{document}

Framebox need to increase 350pt width if Framebox exceed to \textwidth

enter image description here

Marijn
  • 37,699
Rajesh N
  • 829
  • 1
    Could you add the code used to produce the screenshot to your question? It should be a complete document, i.e., starting with \documentclass, then the \usepackage statements (if any), \begin{document}, the contents, and then \end{document}. – Marijn Dec 22 '20 at 12:00
  • Sorry forgotten to add latex macros, tex file updated in the above comments – Rajesh N Dec 22 '20 at 12:12

1 Answers1

1

This looks like an attempt to fix a bad R/knitr output. In this case, you are in the wrong way. Otherwise, this answer might not be the solution, but consider the simplicity of knitr to produce the same output.

\documentclass{book}
\usepackage{lipsum}
\begin{document}
<<options,echo=FALSE>>=
    options(width = 60)
@
\lipsum[5][1-5]
<<seq,background=c(1,.95,.86)>>=
    17:58
@
\lipsum[6][1-4]
\end{document}

mwe

Fran
  • 80,769