Управление ограничивающей рамкой (Bounding Box) в tcolorbox

Управление ограничивающей рамкой (Bounding Box) в tcolorbox в различных вариациях

Управление ограничивающей рамкой (Bounding Box) в tcolorbox

Смещение границ ограничивающей рамки

Параметр Синтаксис Описание Пример
enlarge top initially by /tcb/enlarge top initially by=⟨length⟩ Расширение верхней границы (только для первого бокса) enlarge top initially by=5mm
enlarge bottom finally by /tcb/enlarge bottom finally by=⟨length⟩ Расширение нижней границы (только для последнего бокса) enlarge bottom finally by=5mm
enlarge top at break by /tcb/enlarge top at break by=⟨length⟩ Расширение верхней границы для разорванных частей enlarge top at break by=3mm
enlarge bottom at break by /tcb/enlarge bottom at break by=⟨length⟩ Расширение нижней границы для разорванных частей enlarge bottom at break by=3mm
enlarge top by /tcb/enlarge top by=⟨length⟩ Расширение верхней границы для всех случаев enlarge top by=5mm
enlarge bottom by /tcb/enlarge bottom by=⟨length⟩ Расширение нижней границы для всех случаев enlarge bottom by=5mm
enlarge left by /tcb/enlarge left by=⟨length⟩ Расширение левой границы enlarge left by=2cm
enlarge right by /tcb/enlarge right by=⟨length⟩ Расширение правой границы enlarge right by=2cm
enlarge by /tcb/enlarge by=⟨length⟩ Расширение всех границ enlarge by=5mm

Выравнивание бокса

Параметр Синтаксис Описание Пример
grow to left by /tcb/grow to left by=⟨length⟩ Увеличение ширины влево grow to left by=2cm
grow to right by /tcb/grow to right by=⟨length⟩ Увеличение ширины вправо grow to right by=2cm
grow sidewards by /tcb/grow sidewards by=⟨length⟩ Увеличение ширины в обе стороны grow sidewards by=2cm
flush left /tcb/flush left Выравнивание влево flush left
flush right /tcb/flush right Выравнивание вправо flush right
center /tcb/center Центрирование center

Переключение расширений

Параметр Синтаксис Описание Пример
toggle enlargement /tcb/toggle enlargement=⟨toggle preset⟩ Переключение расширений (none, forced, evenpage) toggle enlargement=evenpage

Растягивание до границ страницы

Параметр Синтаксис Описание Пример
spread inwards /tcb/spread inwards=⟨length⟩ Растягивание к внутреннему краю страницы spread inwards=5mm
spread outwards /tcb/spread outwards=⟨length⟩ Растягивание к внешнему краю страницы spread outwards=5mm
move upwards /tcb/move upwards=⟨length⟩ Перемещение к верхнему краю (с новой страницы) move upwards=5mm
move upwards* /tcb/move upwards*=⟨length⟩ Перемещение к верхнему краю (без новой страницы) move upwards*=5mm
fill downwards /tcb/fill downwards=⟨length⟩ Заполнение до нижнего края fill downwards=5mm
spread upwards /tcb/spread upwards=⟨length⟩ Комбинация: вверх + внутрь + наружу spread upwards=5mm
spread upwards* /tcb/spread upwards*=⟨length⟩ То же без новой страницы spread upwards*=5mm
spread sidewards /tcb/spread sidewards=⟨length⟩ Растягивание в стороны spread sidewards=5mm
spread /tcb/spread=⟨length⟩ Заполнение всей страницы spread=5mm
spread downwards /tcb/spread downwards=⟨length⟩ Комбинация: вниз + внутрь + наружу spread downwards=5mm

Выступание бокса

Параметр Синтаксис Описание Пример
shrink tight /tcb/shrink tight Плотное облегание содержимого shrink tight
extrude left by /tcb/extrude left by=⟨length⟩ Выступание влево extrude left by=1cm
extrude right by /tcb/extrude right by=⟨length⟩ Выступание вправо extrude right by=1cm
extrude top by /tcb/extrude top by=⟨length⟩ Выступание вверх extrude top by=1cm
extrude bottom by /tcb/extrude bottom by=⟨length⟩ Выступание вниз extrude bottom by=1cm
extrude by /tcb/extrude by=⟨length⟩ Выступание во все стороны extrude by=5mm

Примеры использования

1. Расширение границ

\begin{tcolorbox}[
  enlarge left by=2cm,
  enlarge top by=5mm,
  enhanced,
  show bounding box
]
Бокс с расширенными границами
\end{tcolorbox}

2. Растягивание до краев страницы

\begin{tcolorbox}[
  spread sidewards,
  spread upwards,
  height=3cm,
  colframe=blue,
  sharp corners=north
]
Бокс, растянутый до краев страницы
\end{tcolorbox}

3. Выступающие элементы

Текст \tcbox[shrink tight, extrude right by=5mm]{с выступающим} элементом

Особенности работы:

  1. Параметры с * не создают новую страницу
  2. Для визуализации bounding box используйте show bounding box
  3. Комбинированные параметры (spread и др.) экономят время настройки
  4. Выступающие элементы (extrude) не изменяют bounding box