纸张宽度数字周围的背景颜色

纸张宽度数字周围的背景颜色

这个问题的副标题可以是:“如何强制标题始终出现在对象浮动的顶部”。我有一组复杂的配置和命令,可以将其恢复到 MWE。

% !TeX encoding = UTF-8
% !TeX spellcheck = fr_FR

\documentclass[11pt, frenchb, twoside]{report}

% LENGTH
\newlength{\goldenMargin}
\setlength{\goldenMargin}{1.618in}
\newlength{\imageWidth}
\setlength{\imageWidth}{.5\paperwidth}

% IMPORTS
\usepackage{adjustbox}
\usepackage{blindtext}
\usepackage{floatrow}
\usepackage{caption}
\usepackage{ifoddpage}
\usepackage[first=0, last=1, quiet]{lcg}
\usepackage{polyglossia}
\usepackage[paperwidth=8.125in,paperheight=10.25in,
            hmargin={.5\goldenMargin,\goldenMargin},vmargin={.5\goldenMargin},
            marginparwidth={\dimexpr \goldenMargin - 2\marginparsep}]{geometry}
\usepackage[usenames,dvipsnames,svgnames,rgb]{xcolor}
\usepackage{xparse}
\usepackage{xifthen}
\usepackage{xstring}

% % % % % % % % RIGHTLAST % % % % % % % %
\ProvideDocumentCommand \rightlast{}
{\leftskip0ptplus1fil\rightskip0ptplus-1fil\parfillskip0ptplus1fil}

% GRAPHICS
\graphicspath{{../assets/}}

% FLOATS & CAPTIONS
\floatsetup{heightadjust=all}
\DeclareColorBox{blackplate}{\colorbox{black}}
\DeclareFloatStyle{blackFloat}{style=plain,framestyle=colorbox,
        framearound=all,colorframeset=blackplate,frameset={\fboxrule0pt},
        framestyle=colorbox,framefit=yes}

\DeclareFloatSeparators{oddCapSep}{\hspace{\dimexpr -\parindent-.5\goldenMargin}}

\DeclareCaptionLabelFormat{oddLabel}{\fbox{\Large\scshape#1~#2}\hspace*{\fill}}
\DeclareCaptionLabelFormat{evenLabel}{\fbox{\Large\scshape#1~#2}}
\DeclareCaptionLabelSeparator{oddSep}{odd}

\DeclareCaptionFormat{innerCapFormat}
{%
    \parbox{\dimexpr \paperwidth-\imageWidth-\goldenMargin-\parindent-\columnsep}
    {%
        \IfStrEq{#2}{l}
            {\raggedright#1\hspace*{\fill}\bigbreak#3}
            {\rightlast#1\bigbreak#3}
    }
}

\DeclareCaptionStyle{innerCapStyle}%
{%
    singlelinecheck=off,format=innerCapFormat
}

% % % % % % % % UTILS % % % % % % % %
\ExplSyntaxOn
\tl_new:N \l_foo_tl
\tl_new:N \l_bar_tl

\DeclareExpandableDocumentCommand{\IfNoEmptyTF}{ m m m }
{
    \IfNoValueTF{#1}{#2}
    {
        \tl_if_empty:nTF {#1} {#2} {#3}
    }
}

% % % % % % % % BLACKARTWORK % % % % % % % %
% #1 TOC caption
% #2 Caption
% #3 Image Path
\ProvideDocumentCommand \blackArtwork{ m m m }
{
    \adjustboxset{bgcolor=black}
%   \floatsetup[figure]{style=blackFloat}
    \rand\ifthenelse{\equal{\arabic{rand}}{1}}
    {\begin{figure}[t!]}{\begin{figure}[b!]}
        \captionsetup{style=innerCapStyle,font={sf,color=white}}
        \checkoddpage
        \ifthenelse{\boolean{oddpage}}
        {%
            \tl_set:Nn \l_foo_tl {#2\hspace*{\fill}}
            \tl_set:Nn \l_bar_tl {l}
%       \begin{blackbox}
            \adjustboxset{lap=\dimexpr -\parindent - .5\goldenMargin}
            \captionsetup{labelsep=oddSep,labelformat=oddLabel,justification=raggedleft}
        \floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,center},%
                                             capbesidesep=oddCapSep}}]
        }
        {%
            \tl_set:Nn \l_foo_tl {\hspace*{\fill}#2}
            \tl_set:Nn \l_bar_tl {r}
%       \begin{blackbox}
            \adjustboxset{lap=.5\goldenMargin}
            \captionsetup{labelformat=evenLabel}
        \floatbox[{\capbeside\thisfloatsetup{capbesideposition={left,center}}}]
        }
        {figure}
        {\caption[#1]{\l_foo_tl}\label{fig:#3}}
        {\adjustbox{inner}{\makebox[\paperwidth][\l_bar_tl]{\includegraphics[width=\imageWidth]{#3}}}}
%        \end{blackbox}
    \end{figure}
    \adjustboxset{}
}
\ExplSyntaxOff

\ProvideDocumentEnvironment{blackbox}{}
    {\begin{adjustbox}{frame}}
    {\end{adjustbox}}

\begin{document}
\blindtext
\blackArtwork{Miguel Chevalier, \textit{Magic Carpets}, 2014}
             {Miguel Chevalier, Magic Carpets, 2014. Installation générative et interactive de réalité virtuelle. \O~17.5 m. Festival Internazionale di Andria, Castel del Monte.}
             {chevalier_magic-carpets}
\blindtext[3]
\blackArtwork{Zu Doyang, \textit{Mini-mondes oculaires}, 2002--2007}
             {Zu Doyang, \textit{Mini-mondes oculaires}, 2002--2007. Épreuve à développement chromogène, 1.23 $\times$ 1.25 m chacune. Association des musées d'art coréen, Séoul}
             {doyang_spheres}
\end{document}

mwe 输出

随机blackArtwork强制将图形排版在页面顶部 | 底部。背景是通过调整框围绕一个\paperwidth宽框mbox,图形最终包含在其中。您可以看到第二页上没有标题。我的猜测是所有内容都是从左到右排版的,并且对象的“深度”(如果该概念仅存在于 Latex 中)以这种方式给出。因此,在偶数页上,标题排版在图像之前,然后被黑色背景覆盖。我尝试了不同的混合方法,以便将图像和标题封闭在一个\paperwidth具有纯色背景且没有其他边距的框中,但我无法使其工作。

所以也许有一种方法可以强制在图像后排版标题,或者不排版,或者也许我把它复杂化了,而有更好的方法来实现这一点。

答案1

标题移动正在进行中floatrow,您可以修改其左侧位置,将其放置在图像之后但退格,而不是图像之前。我不了解该软件包,所以我可能错过了一些情况,但这在这里有效:

在此处输入图片描述

\documentclass[11pt, frenchb, twoside]{report}

% LENGTH
\newlength{\goldenMargin}
\setlength{\goldenMargin}{1.618in}
\newlength{\imageWidth}
\setlength{\imageWidth}{.5\paperwidth}

% IMPORTS
\usepackage{adjustbox}
\usepackage{blindtext}
\usepackage{floatrow}

\makeatletter
\renewcommand\flrow@FC@{\global\let\flrow@typ@tmpset\undefined
 \FB@frame{\begin@FBBOX
   \adj@dim\FBo@wd+\FBo@wadj=\hsize
   \settowidth\@tempdimb{\floatcapbesidesep}\advance\hsize\@tempdimb
   \advance\hsize\FBc@wd\@parboxrestore\leftmargin\z@\rightmargin\z@
   \@@FBabove
    \hbox{%
\floatfacing*%
      {%
\ifvoid\@floatcapt\else
\kern\FBc@wd
          \floatcapbesidesep
\fi
       \FBf@raise{\FBo@frame{\FCo@box{\FBw@box\FBc@wd\unvbox\@currbox}}}%%
\ifvoid\@floatcapt\else
\rlap{\kern-\FBc@wd\kern-\columnsep\kern-\wd\@floatcapt
         \FCc@box{\FBw@box\FBc@wd\unvbox\@floatcapt\FB@foot}}%
\fi
}%
{\FBf@raise{\FBo@frame{\FCo@box{\FBw@box\FBo@wd\unvbox\@currbox}}}%
       \ifvoid\@floatcapt\else
         \floatcapbesidesep\FCc@box{\FBw@box\FBc@wd
           \unvbox\@floatcapt\FB@foot}\fi
      }%
%
}%
\par\@@FBbelow\vskip\z@
    \end@FBBOX
    \global\setbox\@floatcapt\box\voidb@x}}
\makeatother


\usepackage{caption}
\usepackage{ifoddpage}
\usepackage[first=0, last=1, quiet]{lcg}
\usepackage{polyglossia}
\usepackage[paperwidth=8.125in,paperheight=10.25in,
            hmargin={.5\goldenMargin,\goldenMargin},vmargin={.5\goldenMargin},
            marginparwidth={\dimexpr \goldenMargin - 2\marginparsep}]{geometry}
\usepackage[usenames,dvipsnames,svgnames,rgb]{xcolor}
\usepackage{xparse}
\usepackage{xifthen}
\usepackage{xstring}

% % % % % % % % RIGHTLAST % % % % % % % %
\ProvideDocumentCommand \rightlast{}
{\leftskip0ptplus1fil\rightskip0ptplus-1fil\parfillskip0ptplus1fil}

% GRAPHICS
\graphicspath{{../assets/}}

% FLOATS & CAPTIONS
\floatsetup{heightadjust=all}
\DeclareColorBox{blackplate}{\colorbox{black}}
\DeclareFloatStyle{blackFloat}{style=plain,framestyle=colorbox,
        framearound=all,colorframeset=blackplate,frameset={\fboxrule0pt},
        framestyle=colorbox,framefit=yes}

\DeclareFloatSeparators{oddCapSep}{\hspace{\dimexpr -\parindent-.5\goldenMargin}}

\DeclareCaptionLabelFormat{oddLabel}{\fbox{\Large\scshape#1~#2}\hspace*{\fill}}
\DeclareCaptionLabelFormat{evenLabel}{\fbox{\Large\scshape#1~#2}}
\DeclareCaptionLabelSeparator{oddSep}{odd}

\DeclareCaptionFormat{innerCapFormat}
{%
    \parbox{\dimexpr \paperwidth-\imageWidth-\goldenMargin-\parindent-\columnsep}
    {%
        \IfStrEq{#2}{l}
            {\raggedright#1\hspace*{\fill}\bigbreak#3}
            {\rightlast#1\bigbreak#3}
    }
}

\DeclareCaptionStyle{innerCapStyle}%
{%
    singlelinecheck=off,format=innerCapFormat
}

% % % % % % % % UTILS % % % % % % % %
\ExplSyntaxOn
\tl_new:N \l_foo_tl
\tl_new:N \l_bar_tl

\DeclareExpandableDocumentCommand{\IfNoEmptyTF}{ m m m }
{
    \IfNoValueTF{#1}{#2}
    {
        \tl_if_empty:nTF {#1} {#2} {#3}
    }
}

% % % % % % % % BLACKARTWORK % % % % % % % %
% #1 TOC caption
% #2 Caption
% #3 Image Path
\ProvideDocumentCommand \blackArtwork{ m m m }
{
    \adjustboxset{bgcolor=black}
%   \floatsetup[figure]{style=blackFloat}
    \rand\ifthenelse{\equal{\arabic{rand}}{1}}
    {\begin{figure}[t!]}{\begin{figure}[b!]}
        \captionsetup{style=innerCapStyle,font={sf,color=white}}
        \checkoddpage
        \ifthenelse{\boolean{oddpage}}
        {%
            \tl_set:Nn \l_foo_tl {#2\hspace*{\fill}}
            \tl_set:Nn \l_bar_tl {l}
%       \begin{blackbox}
            \adjustboxset{lap=\dimexpr -\parindent - .5\goldenMargin}
            \captionsetup{labelsep=oddSep,labelformat=oddLabel,justification=raggedleft}
        \floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,center},%
                                             capbesidesep=oddCapSep}}]
        }
        {%
            \tl_set:Nn \l_foo_tl {\hspace*{\fill}#2}
            \tl_set:Nn \l_bar_tl {r}
%       \begin{blackbox}
            \adjustboxset{lap=.5\goldenMargin}
            \captionsetup{labelformat=evenLabel}
        \floatbox[{\capbeside\thisfloatsetup{capbesideposition={left,center}}}]
        }
        {figure}
        {\caption[#1]{\l_foo_tl}\label{fig:#3}}
        {\adjustbox{inner}{\makebox[\paperwidth][\l_bar_tl]{\includegraphics[width=\imageWidth]{#3}}}}
%        \end{blackbox}
    \end{figure}
    \adjustboxset{}
}
\ExplSyntaxOff

\ProvideDocumentEnvironment{blackbox}{}
    {\begin{adjustbox}{frame}}
    {\end{adjustbox}}

\begin{document}
\blindtext
\blackArtwork{Miguel Chevalier, \textit{Magic Carpets}, 2014}
             {Miguel Chevalier, Magic Carpets, 2014. Installation générative et interactive de réalité virtuelle. \O~17.5 m. Festival Internazionale di Andria, Castel del Monte.}
             {example-image}
\blindtext[3]
\blackArtwork{Zu Doyang, \textit{Mini-mondes oculaires}, 2002--2007}
             {Zu Doyang, \textit{Mini-mondes oculaires}, 2002--2007. Épreuve à développement chromogène, 1.23 $\times$ 1.25 m chacune. Association des musées d'art coréen, Séoul}
             {example-image-a}
\end{document}

相关内容