使用 tcbraster 分割页面

使用 tcbraster 分割页面

我想使用“tcbraster”拆分我的文档,但它不起作用

  • 我指的是分页,类似于你在@Christian Hupfer 在这篇文章中所做的那样 将页面拆分为两个相互独立的内容

  • 我尝试减少我的代码:

    \documentclass[11pt,a4paper]{report}
    \usepackage[margin=0.5in]{geometry}
    \usepackage{multicol}
    \usepackage[french]{babel}
    \usepackage{fontspec}
    \usepackage{graphicx}
    \usepackage{amsthm,amssymb,amsfonts,mathtools}
    \newcommand{\centerbox}[1]% #1 = text
    {\bgroup% use local definitions
      \parskip=0pt
      \sbox0{\fbox{#1}}
      \dimen0=\dimexpr 0.5\textwidth - 0.5\wd0\relax
      \par\noindent\rule{\dimen0}{0.8pt}\box0\rule{\dimen0}{0.8pt}\par
    \egroup}
    
    \usepackage{xhfill}
    \usepackage{fancyhdr}
    %\usepackage{xcolor}
    %\usepackage{tcolorbox}
    \usepackage[svgnames]{xcolor}
    %\usepackage[most]{tcolorbox}
    \tcbuselibrary{skins,breakable,xparse}
    \usepackage{tikz}
      \usetikzlibrary{shapes,arrows,fit,calc,positioning}
      \tikzset{box/.style={draw, rectangle, thick, text centered, minimum height=3em}}
      \tikzset{line/.style={draw, thick, -latex'}}
    
    \newlength\TextBoxWd% width of the text boxes
    \newlength\TextBoxSep% separation of the text boxes
    \newlength\TextBoxHt% height of the text boxes
    
    \setlength\TextBoxWd{\marginparwidth}
    \setlength\TextBoxSep{\marginparsep}
    \setlength\TextBoxHt{2cm}
    
    \newcommand\ThickTitleRule{\xrfill[0.5ex]{3pt}}
    
    \newcommand\Title[4]{%
    \begingroup
      \setlength\parindent{0pt}%
      \par
      \makebox[\linewidth]{%
       % \fbox{\parbox[t][\TextBoxHt][c]{\TextBoxWd}{\raggedright#3}}\hspace{\TextBoxSep}%
        \parbox[t]{\textwidth}{%
          \leavevmode
          \centering
          \ThickTitleRule\quad{\scshape\bfseries\itshape#1}\quad\ThickTitleRule\par
          \vskip-0.2\baselineskip
          \rule{\textwidth}{2pt}\par\vskip-.8\baselineskip% Thick horizontal line
          \rule{\textwidth}{0.4pt}%Thin horizontal line
          \par\vskip0.75ex
          {\Large\scshape\bfseries\itshape#2\par}% Title
          \rule{\textwidth}{0.4pt}\par\par\vskip-.7\baselineskip% Thin horizontal line
          \rule{\textwidth}{2pt}% Thick horizontal line
        }%
       % \hspace{\TextBoxSep}\fbox{\parbox[t][\TextBoxHt][c]{\TextBoxWd}{\raggedright#4}}\par%
      }%
      \vskip\baselineskip
    \endgroup
    }
    
    \begin{document}
    
    \Title{Mohcine}{Educ}{}{}
    \bigskip
    
    \noindent\rule{\textwidth}{0.8pt}
    
    \begin{tcbraster}[raster columns=2,raster equal height=rows,raster valign=top,raster column skip=5mm]
    
    \centerbox{Exercice 1}%
    Soient $a$ et $b$ deux ombres réels non nuls. Montrer que :
    \[3+\frac{a^2}{b^2}+\frac{b^2}{a^2}\ge 2\left(\frac{a}{b}+\frac{b}{a}\right)\]
    
    \centerbox{Solution de l'exercice 1}
    \subsection*{\fbox{Méthode 1}}
         \begin{description}
        \item[]
        \end{description}
        Soit $a,b\in\mathbb{R}^*$
    
        Posons $t=\dfrac{a}{b}+\dfrac{b}{a}$ , on a :
        \[
          \begin{aligned}
             & 3+\frac{a^2}{b^2}+\frac{b^2}{a^2}\ge
             2\left(\frac{a}{b}+\frac{b}{a}\right) \\
             \iff &
            3+\frac{a^2}{b^2}+\frac{b^2}{a^2}-2\left(\frac{a}{b}+\frac{b}{a}\right) \geq 0\\
            \iff  & t^{2}-2t+1\geq 0\\
            \iff & \left(t-1\right)^{2}\geq 0
          \end{aligned}
        \]
        comme on a $\forall t\in \mathbb{R}\quad (t-1)^{2}\geq 0$ une
        proposition vraie alors la proposition
        \[
          \forall a,b\in \mathbb{R}^*\quad
          3+\frac{a^2}{b^2}+\frac{b^2}{a^2}\ge
          2\left(\frac{a}{b}+\frac{b}{a}\right)
        \]
        est vraie
            \centerbox{Exercice 2}%
    Bla Bla Bla 
    \centerbox{Solution de l'exercice 2}
    Bla bla bla
    \end{tcbraster}
    
    \end{document}
    

答案1

这是一个初步的解决方案。我没有清除所有不必要的东西。正如@ChrstianHupref 所说,环境tcbraster必须仅包含tcolorbox或相关(甚至不能包含空行!)。顺便说一句,它说的是练习 2 的解决方案,应该是 1。你应该使用带有and 的\par适当计数器。\label\ref

\documentclass[11pt,a4paper]{report}
\usepackage[margin=0.5in]{geometry}
\usepackage{multicol}
\usepackage[french]{babel}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{amsthm,amssymb,amsfonts,mathtools}
% \newcommand{\centerbox}[1]% #1 = text
% {\bgroup% use local definitions
%   \parskip=0pt
%   \sbox0{\fbox{#1}}
%   \dimen0=\dimexpr 0.5\textwidth - 0.5\wd0\relax
%   \par\noindent\rule{\dimen0}{0.8pt}\box0\rule{\dimen0}{0.8pt}\par
% \egroup}

\usepackage[svgnames]{xcolor}
\usepackage{xhfill}
\usepackage{fancyhdr}
%\usepackage{xcolor}
\usepackage{tcolorbox}
%\usepackage[most]{tcolorbox}
\tcbuselibrary{skins,breakable,xparse,raster}
\usepackage{tikz}
  \usetikzlibrary{shapes,arrows,fit,calc,positioning}
  \tikzset{box/.style={draw, rectangle, thick, text centered, minimum height=3em}}
  \tikzset{line/.style={draw, thick, -latex'}}

\newlength\TextBoxWd% width of the text boxes
\newlength\TextBoxSep% separation of the text boxes
\newlength\TextBoxHt% height of the text boxes

\setlength\TextBoxWd{\marginparwidth}
\setlength\TextBoxSep{\marginparsep}
\setlength\TextBoxHt{2cm}

\newcommand\ThickTitleRule{\xrfill[0.5ex]{3pt}}

\newcommand\Title[4]{%
\begingroup
  \setlength\parindent{0pt}%
  \par
  \makebox[\linewidth]{%
   % \fbox{\parbox[t][\TextBoxHt][c]{\TextBoxWd}{\raggedright#3}}\hspace{\TextBoxSep}%
    \parbox[t]{\textwidth}{%
      \leavevmode
      \centering
      \ThickTitleRule\quad{\scshape\bfseries\itshape#1}\quad\ThickTitleRule\par
      \vskip-0.2\baselineskip
      \rule{\textwidth}{2pt}\par\vskip-.8\baselineskip% Thick horizontal line
      \rule{\textwidth}{0.4pt}%Thin horizontal line
      \par\vskip0.75ex
      {\Large\scshape\bfseries\itshape#2\par}% Title
      \rule{\textwidth}{0.4pt}\par\par\vskip-.7\baselineskip% Thin horizontal line
      \rule{\textwidth}{2pt}% Thick horizontal line
    }%
   % \hspace{\TextBoxSep}\fbox{\parbox[t][\TextBoxHt][c]{\TextBoxWd}{\raggedright#4}}\par%
  }%
  \vskip\baselineskip
\endgroup
}

\usepackage[printwatermark]{xwatermark}
%\usepackage{xcolor}


\newwatermark[allpages,color= magenta!30,angle=45,scale=3,xpos=0,ypos=0]{Mohcine }

\newtcolorbox{centerbox}[2][]{colback=white, colframe=black!75,fonttitle=\normalfont,
  colbacktitle=white, coltitle=black,
  enhanced, attach boxed title to top center={yshift=-3mm},
  title=#2,#1}

%========================================================================================
\begin{document}

\Title{Mohcine}{Educ}{}{}
\bigskip
%\begin{LTR}
\noindent\rule{\textwidth}{0.8pt}

\begin{tcbraster}[raster columns=2,raster equal height=rows,raster valign=top]%,raster column skip=5mm]
%
  \begin{centerbox}{Exercice 1}%
    Soient $a$ et $b$ deux ombres réels non nuls. Montrer que :
    \[
      3+\frac{a^2}{b^2}+\frac{b^2}{a^2}\ge
      2\left(\frac{a}{b}+\frac{b}{a}\right)
    \]
  \end{centerbox}
 % 
  \begin{centerbox}{Solution de l'exercice 2}
    \subsection*{\fbox{Méthode 1}}
    \begin{description}
    \item[]
    \end{description}
    Soit $a,b\in\mathbb{R}^*$

    Posons $t=\dfrac{a}{b}+\dfrac{b}{a}$ , on a :
    \[
      \begin{aligned}
         & 3+\frac{a^2}{b^2}+\frac{b^2}{a^2}\ge
         2\left(\frac{a}{b}+\frac{b}{a}\right) \\
         \iff &
        3+\frac{a^2}{b^2}+\frac{b^2}{a^2}-2\left(\frac{a}{b}+\frac{b}{a}\right) \geq 0\\
        \iff  & t^{2}-2t+1\geq 0\\
        \iff & \left(t-1\right)^{2}\geq 0
      \end{aligned}
    \]
    comme on a $\forall t\in \mathbb{R}\quad (t-1)^{2}\geq 0$ une
    proposition vraie alors la proposition
    \[
      \forall a,b\in \mathbb{R}^*\quad
      3+\frac{a^2}{b^2}+\frac{b^2}{a^2}\ge
      2\left(\frac{a}{b}+\frac{b}{a}\right)
    \]
    est vraie
  \end{centerbox}
%
  \begin{centerbox}{Exercice 2}%
    \subsection*{\fbox{Méthode 2}}
\end{centerbox}
\end{tcbraster}
%\end{LTR}

\end{document}

在此处输入图片描述

相关内容