5

In this question, Measure distance from text to bottom margin, an answer is using tcolorbox to provide a box that fills the remaining length of the page. However, when the box is indented by, say, an itemize environment, the width of the box is not reduced and the box width exceeds the right paper margin. How may I achieve the correct width of this tcolorbox?

\documentclass[]{article}

\usepackage[showframe]{geometry}
\usepackage[utf8]{inputenc}

\usepackage[most]{tcolorbox}
\tcbuselibrary{breakable}
\newtcbox{example}[1][]{%
  enhanced jigsaw,
  colback=white, 
  colframe=black,
  boxrule=1pt,
  sharpish corners,
  arc=0mm,
  boxsep=0mm,
  left=\dimexpr\textwidth-2pt\relax,   %% 2pt= 2* boxrule width (1pt)
  right=0mm,
  % width fill,
  height fill,   %% <---- this fills the remaining space
  #1,
}

\begin{document} 
Itemized list
\begin{itemize}
    \item Itemized \example{\null}
\end{itemize}
\end{document} 
6
 left=\dimexpr\linewidth-2pt\relax,   %% 2pt= 2* boxrule width (1pt)

not \textwidth

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.