为什么框和图像之间会有很大的空隙?

为什么框和图像之间会有很大的空隙?

结果如下: 在此处输入图片描述

文件如下:

% 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}{-2}
\setcounter{tocdepth}{5}
\setlength{\parindent}{0bp}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}

\makeatletter

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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]
\AtBeginDocument{\make@lr\thetheorem}

% 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.
\newfontfamily\hebrewfont[Script=Hebrew]{Ezra SIL}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Yehuda CLM}
\setlength{\columnseprule}{0.4pt}
\renewcommand{\labelenumi}{\alph{enumi}.}
\AtBeginDocument{
\renewcommand\footnoterule{%
  \kern -3pt
  \hbox to \textwidth{\hfill\vrule height 0.4pt width .4\textwidth}
  \kern 2.6pt
}}
\usepackage[explicit]{titlesec}
\usepackage[x11names,usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[many]{tcolorbox}

%For the part:
\tcbset{enhanced,colback=green!5!white,colframe=Gold!75!black}

\titleformat{\part}[display]
  {\normalfont\bfseries\Huge\selectfont}
  {}{0pt}
  {\begin{tcolorbox}[show bounding box,drop large lifted shadow=DarkGoldenrod1, colback=LightGoldenrod1,colframe=Gold1!75!black, halign=center, valign=center]
    {#1}\end{tcolorbox}}[]

\makeatother

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
\begin{singlespace}

\part{Stam Stam Stam}
\end{singlespace}
\begin{singlespace}
\noindent \begin{center}
\includegraphics[scale=0.5]{nat}
\par\end{center}
\end{singlespace}




\end{document}

如果你需要图片: 在此处输入图片描述

我怎样才能缩小框与图像之间的空间?

谢谢你!!

答案1

我对序言进行了一些重新组织:最好先加载包,然后进行设置。

也不titlesec需要使用explicit选项来调用。我发现通常最好为该工作定义一个合适的宏。

部分标题的“单个空间”最好作为设置的一部分进行选择,而不是明确添加环境singlespace(参见如何\titleformat重写)。

为了减少空间,添加一个负数\vspace

抱歉,更改了字体,但我没有和你一样的字体。

\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{fancyhdr}
\usepackage{polyglossia}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{theorem}
\usepackage{titlesec}
\usepackage[x11names,usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[many]{tcolorbox}

\usepackage{lipsum}

\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}

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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\pagestyle{fancy}
\setcounter{secnumdepth}{-2}
\setcounter{tocdepth}{5}
\setlength{\parindent}{0bp}

\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]

\makeatletter
\AtBeginDocument{\make@lr\thetheorem}

% 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.
\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{David CLM}
\setlength{\columnseprule}{0.4pt}
\renewcommand{\labelenumi}{\alph{enumi}.}
\AtBeginDocument{
\renewcommand\footnoterule{%
  \kern -3pt
  \hbox to \textwidth{\hfill\vrule height 0.4pt width .4\textwidth}
  \kern 2.6pt
}}

%For the part:

\newcommand{\makeparttitle}[1]{%
  \begin{tcolorbox}[
    enhanced,
    colback=green!5!white,
    colframe=Gold!75!black,
    show bounding box,
    drop large lifted shadow=DarkGoldenrod1,
    colback=LightGoldenrod1,
    colframe=Gold1!75!black,
    halign=center,
    valign=center,
  ]
  #1
  \end{tcolorbox}%
}

\titleformat{\part}[display]
  {\singlespacing\normalfont\bfseries\Huge\selectfont}
  {}{0pt}
  {\makeparttitle}

\makeatother

\setdefaultlanguage{hebrew}
\setotherlanguage{english}

\begin{document}

\part{Stam Stam Stam}

\vspace*{-8ex plus -1ex minus -1ex}

\begin{center}
\centering
\includegraphics[scale=0.5]{example-image} 
\end{center}

\part{Stam Stam Stam\\Stam Stam}

\lipsum[1]

\end{document}

在此处输入图片描述

相关内容