为什么框中的文字不在中心?

为什么框中的文字不在中心?

看看下面的代码:

 % Preview source code

%% LyX 2.3.0 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[a4paper,english,hebrew]{article}
\usepackage{fontspec}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{1}
\setcounter{tocdepth}{5}
\setlength{\parindent}{0bp}
\usepackage{color}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 0},pdfborderstyle={},backref=false,colorlinks=true]
 {hyperref}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}

% The following chunk fixes export with XeTeX.
% It is needed because polyglossia is used by default
% and \make@lr is only defined by babel.
\@ifundefined{make@lr}
{\def\make@lr#1{\begingroup
    \toks@=\expandafter{#1}%
    \edef\x{\endgroup
  \def\noexpand#1{\noexpand\@number{\the\toks@}}}%
  \x}}{\relax}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\usepackage[many]{tcolorbox}
\usepackage[framemethod=TikZ,framemethod=pstricks]{mdframed}
\tcbset{enhanced,colback=red!5!white,
    boxrule=0pt,
    colframe=blue!75!black,fonttitle=\bfseries}
\titleformat{\part}
  {\normalfont\bfseries\Huge\selectfont}
  {}{0pt}
  {\begin{tcolorbox}[drop large lifted shadow=black,halign=center]
    \center{Part\hskip0.7em\thepart\newline#1}\end{tcolorbox}}[]

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
\begin{english}[variant=american]%

\part{Simple}

\end{english}%
\tableofcontents{}
\end{document}

结果如下:

在此处输入图片描述

Part I不在中心是什么样的Simple

谢谢你!

答案1

仅使用

\begin{tcolorbox}[drop large lifted shadow=black,halign=center]
{Part~\thepart\\#1}
\end{tcolorbox}

在此处输入图片描述

相关内容