![目录中左对齐](https://linux22.com/image/438244/%E7%9B%AE%E5%BD%95%E4%B8%AD%E5%B7%A6%E5%AF%B9%E9%BD%90.png)
我创建了一个 tcolorbox 环境,在我的数学课上用方框显示活动的名称。MWE:
\documentclass[12pt,a4paper]{report}
\usepackage{lipsum}
\usepackage{docstyle}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\renewcommand{\doctitle}{Statistiques}
\newcommand{\auteur}{Nom Professeur}
\newcommand{\studyprogram}{Terminales}
\newcommand{\suni}{Mathématiques}
\newcommand*\ruleline[1]{\par\noindent\raisebox{.8ex}{\makebox[\linewidth]{\hrulefill\hspace{1ex}\raisebox{-.8ex}{#1}\hspace{1ex}\hrulefill}}}
\newcommand{\summary}[1]{\addtocontents{toc}{#1\par}}
% Contenu du Docstyle
%\ProvidesPackage{docstyle}
\addto\captionsfrench{\def\tablename{{Tableau}}}
\addto{\captionsfrench}{\renewcommand{\abstractname}{Compétences à acquérir}}
% Layout packages
\usepackage{lmodern}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{fancyhdr}
\fancypagestyle{firststyle}
{
\fancyhf{}
\renewcommand\headrulewidth{1pt}
\fancyhead[L]{\LaTeX \quad C'est super!}
\fancyhead[R]{Académie de Poitiers}
\fancyfoot[C]{Rubrique \LaTeX}
\fancyfoot[R]{\today}
}
\usepackage{colortbl}
\usepackage[some]{background}
\usetikzlibrary{calc}
\usepackage{graphicx}
\usepackage{newtxtext}
\usepackage{comment}
\usepackage{xcolor}
\definecolor{aquamarine}{rgb}{0.5, 1.0, 0.83} % Couleurs à partir de http://latexcolor.com
\usepackage{placeins}
\usepackage{wrapfig}
\usepackage[letterpaper, left=3cm,right=2cm,top=2.5cm,bottom=2.5cm, headheight=15pt]{geometry}
\usepackage{hyperref}
\hypersetup{colorlinks, allcolors=black}
% References
\usepackage{csquotes}
\usepackage[style=alphabetic,backend=biber]{biblatex}
\addbibresource{references.bib}
% Sciences and Math packages
\usepackage{semtrans}
\usepackage{array}
\usepackage{textgreek}
\usepackage{amsmath}
\usepackage{fixltx2e}
\usepackage{multido}
\usepackage{mathrsfs}
\usepackage{frcursive}
\usepackage{capt-of}
\usepackage{tabulary}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\usepackage{float}
\restylefloat{table}
% Horizontal line and separator
%\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
%\newcommand{\hseparator}{\hspace{0.3em}-\hspace{0.3em}}
% !!!!!!! Header des pages !!!!!
\lhead{\suni\hseparator\studyprogram}
\rhead{\doctitle}
\usepackage{enumitem}
\usepackage{sectsty}
\usepackage{lipsum}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\parindent=0mm
\usepackage[most]{tcolorbox}
\newtcolorbox[number within=section,list inside=toc]{activite}[1]{enhanced,
attach boxed title to top center={yshift=-2mm,yshifttext=-2mm},
colback=aquamarine!8,
colframe=aquamarine!2!black,
colbacktitle=aquamarine!8,
title={#1},
fonttitle=\bfseries,
fontupper=\bfseries,
coltext=black,
coltitle=black,
boxed title style={size=small,colframe=black}
}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother
\renewcommand{\thechapter}{\Roman{chapter}.}
\renewcommand\thesection{\arabic{section}}
\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\alph{subsection})}
\begin{document}
\tableofcontents
\addtocontents{toc}{
\protect\thispagestyle{empty}}
\thispagestyle{empty}
\newpage
\pagenumbering{arabic}
\pagestyle{fancy}
\renewcommand{\partname}{Activité}
\addtocontents{toc}{\vskip15pt \ruleline{\bfseries Activités} \vspace{1mm}}
\begin{activite}
{Activité 1}{Nom de l'activité}
\end{activite}
\lipsum[1-1]
\begin{activite}
{Activité 2}{Nom de l'activité}
\end{activite}
\lipsum[1-1]
\begin{activite}
{Activité 3}{Nom de l'activité}
\end{activite}
\lipsum[1-1]
\begin{activite}
{Activité 4}{Nom de l'activité}
\end{activite}
\lipsum[1-1]
\end{document}
环境“Activite”的创建方式如下:
\newtcolorbox[number within=section,list inside=toc]{activite}[1]{enhanced,
attach boxed title to top center={yshift=-2mm,yshifttext=-2mm},
colback=aquamarine!8,
colframe=aquamarine!2!black,
colbacktitle=aquamarine!8,
title={#1},
fonttitle=\bfseries,
fontupper=\bfseries,
coltext=black,
coltitle=black,
boxed title style={size=small,colframe=black}
}
代码的一部分[number within=section,list inside=toc]
用于在目录中添加信息。但问题是,在目录中,内容没有在左侧对齐(如图所示)。有人有什么想法可以帮助我吗?谢谢!Antoine