tcolorbox 内的边注

tcolorbox 内的边注

tcolorbox我为编写问题解决方案创建了一些想法:

\documentclass{scrartcl}
\usepackage[breakable, many]{tcolorbox}
\usepackage{changepage}
\usepackage{lipsum}
\NewTColorBox[auto counter,number within=section]{solution}{+O{}}{%
    breakable, enhanced,sharpish corners, colframe=blue!50,colback=white,coltitle=blue!60!black,
    fonttitle=\itshape\bfseries, parbox = false,
    check odd page,toggle left and right,
    boxrule=0.3mm,top=0mm,bottom=0mm,left=2.1cm,right=1mm,
    %grow to right by=1cm,
    %toprule=1mm,
    overlay={%
        \ifoddpage%
        \draw[red!75!black,line width=1pt]
        ([xshift=2.02cm]frame.north west)--([xshift=2.02cm]frame.south west);%
        \else%
        \draw[red!75!black,line width=1pt]
        ([xshift=-1.95cm]frame.north east)--([xshift=-1.95cm]frame.south east);%
        \fi%
        },
    underlay={\begin{tcbclipinterior}
            \draw[help lines,step=5mm,blue!20!white,shift={(interior.north west)}]
            (interior.south west) grid (interior.north east);
            \end{tcbclipinterior}},
        title={solution},
        label={},
        attach title to upper=\quad,
        after upper={\par\hfill%
            {}},
        lowerbox=ignored,
    }

\begin{document}

        \begin{solution}
        \lipsum[1-40]
        \end{solution}

\end{document}

在此处输入图片描述

我需要tcolorbox红线后面有边注的功能。如果红线后面的字段与当前页边距的实际大小一致就好了

答案1

我不确定以下是否是您要寻找的解决方案。该框延伸到页边距并marginnote用于添加边距注释:

\documentclass[twoside]{scrartcl}
\usepackage[breakable, many]{tcolorbox}
\usepackage{changepage}
\usepackage{lipsum,marginnote}

\NewTColorBox[auto counter,number within=section]{solution}{+O{}}{%
  breakable, enhanced,sharpish corners, colframe=blue!50,colback=white,coltitle=blue!60!black,
  fonttitle=\itshape\bfseries, parbox = false,
  check odd page,
  boxrule=0.3mm,top=0mm,bottom=0mm,
  left=1mm,
  right=\the\dimexpr\marginparsep+\marginparwidth+1mm\relax,
  grow to right by=\the\dimexpr\marginparsep+\marginparwidth+1mm\relax,
  toggle left and right,
  toggle enlargement,
  underlay={%
    \begin{tcbclipinterior}
      \draw[help lines,step=5mm,blue!20!white,shift={(interior.north west)}]
      (interior.south west) grid (interior.north east);
      \ifodd\value{page}%
        \draw[red!75!black,line width=1pt]
        ([xshift=-\the\dimexpr\marginparsep/2+\marginparwidth+2mm\relax]frame.north east)
        --([xshift=-\the\dimexpr\marginparsep/2+\marginparwidth+2mm\relax]frame.south east);%
      \else%
        \draw[red!75!black,line width=1pt]
        ([xshift=\the\dimexpr\marginparsep/2+\marginparwidth+2mm\relax]frame.north west)
        --([xshift=\the\dimexpr\marginparsep/2+\marginparwidth+2mm\relax]frame.south west);%
      \fi%
    \end{tcbclipinterior}},
  title={solution},
  label={},
  attach title to upper=\quad,
  after upper={\par\hfill%
      {}},
  lowerbox=ignored,
  #1
  }

\begin{document}

  \begin{solution}
  \lipsum[1]
  \marginnote{\small Bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla}
  \lipsum[2-8]
  \marginnote{\small Bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla}
  \lipsum[9-40]
  \end{solution}

\end{document}

在此处输入图片描述 在此处输入图片描述

相关内容