1\NeedsTeXFormat{LaTeX2e}[1995/12/01] 2\ProvidesPackage{mznstyle}[2016/12/18 LaTeX package (MiniZinc for Sphinx)] 3 4\RequirePackage{trace} 5\RequirePackage[breakable]{tcolorbox} 6\RequirePackage{caption} 7\PassOptionsToPackage{hanging,nooneline}{caption} 8 9\RequirePackage{chngcntr} 10 11\RequirePackage{inputenc} 12\PassOptionsToPackage{utf8}{inputenc} 13 14\counterwithin{chapter}{part} 15\renewcommand{\thepart}{\arabic{part}} 16 17%\definecolor{UglyGreen}{rgb}{0,1,0} 18\definecolor{UglyGreen}{rgb}{0.418,0.556,0.137} 19%\definecolor{UglyBlue}{rgb}{0,0,1} 20\definecolor{UglyBlue}{rgb}{0.273,0.508,0.703} 21%\definecolor{UglyRed}{rgb}{0.2,0,0} 22\definecolor{UglyRed}{rgb}{0.801,0.359,0.359} 23%\definecolor{UglyOrange}{rgb}{0.2,0,0} 24\definecolor{UglyOrange}{rgb}{0.930,0.906,0.664} 25 26\DeclareCaptionFont{white}{\color{white}} 27 28 29\RequirePackage{tocloft} 30\PassOptionsToPackage{titles}{tocloft} 31 32\setcounter{tocdepth}{4} 33\renewcommand*\cftchapnumwidth{2em} 34\renewcommand*\cftsecnumwidth{3em} 35\renewcommand*\cftsubsecnumwidth{4em} 36 37\renewenvironment{sphinxadmonition}[2]{ 38 \begin{tcolorbox}[colbacktitle=UglyBlue,coltitle=white,colframe=UglyBlue,fonttitle=\bfseries\large,title=#2] 39}{\end{tcolorbox}} 40 41\tcbset{boxrule=0.4pt} 42 43\newtcolorbox[auto counter,number within=chapter]{codebox}[2][]{% 44 title=\textbf{Listing~\thetcbcounter:} #2,#1} 45 46\renewcommand\sphinxcaption[2][\linewidth]{% 47 \noindent\hb@xt@\linewidth{\hss 48 \vtop{\@tempdima\dimexpr#1\relax 49% don't exceed linewidth for the caption width 50 \ifdim\@tempdima>\linewidth\hsize\linewidth\else\hsize\@tempdima\fi 51% longtable ignores \abovecaptionskip/\belowcaptionskip, so add hooks here 52% to uniformize control of caption distance to tables 53 \abovecaptionskip\sphinxabovecaptionskip 54 \belowcaptionskip\sphinxbelowcaptionskip 55 \caption[{#2}]% 56 {\strut\ignorespaces#2\ifhmode\unskip\@finalstrut\strutbox\fi}% 57 }\hss}% 58 \par\prevdepth\dp\strutbox 59}% 60 61\renewenvironment{sphinxVerbatim}{% 62 % first, let's check if there is a caption 63 \ifx\sphinxVerbatimTitle\empty 64 \sphinxvspacefixafterfrenchlists 65 % \parskip\z@skip 66 \vskip\sphinxverbatimsmallskipamount 67 % there was no caption. Check if nevertheless a label was set. 68 \ifx\sphinxLiteralBlockLabel\empty\else 69 % we require some space to be sure hyperlink target from \phantomsection 70 % will not be separated from upcoming verbatim by a page break 71 \needspace{\sphinxliteralblockwithoutcaptionneedspace}% 72 \phantomsection\sphinxLiteralBlockLabel 73 \fi 74 \else 75 \parskip\z@skip 76 \if t\spx@opt@literalblockcappos 77 \vskip\spx@abovecaptionskip 78 \def\sphinxVerbatim@Before 79 {\sphinxVerbatim@Title\nointerlineskip 80 \kern\dimexpr-\dp\strutbox+\sphinxbelowcaptionspace\relax}% 81 \else 82 \vskip\sphinxverbatimsmallskipamount 83 \def\sphinxVerbatim@After 84 {\nointerlineskip\kern\dp\strutbox\sphinxVerbatim@Title}% 85 \fi 86 \def\@captype{literalblock}% 87 \capstart 88 % \sphinxVerbatimTitle must reset color 89 % \setbox\sphinxVerbatim@TitleBox 90 % \hbox{\begin{minipage}{\linewidth}% 91 % \sphinxVerbatimTitle 92 % \end{minipage}}% 93 \fi 94 \fboxsep\sphinxverbatimsep \fboxrule\sphinxverbatimborder 95 \ifspx@opt@verbatimwithframe\else\fboxrule\z@\fi 96 \let\FrameCommand \sphinxVerbatim@FrameCommand 97 \let\FirstFrameCommand\sphinxVerbatim@FirstFrameCommand 98 \let\MidFrameCommand \sphinxVerbatim@MidFrameCommand 99 \let\LastFrameCommand \sphinxVerbatim@LastFrameCommand 100 \ifspx@opt@verbatimhintsturnover\else 101 \let\sphinxVerbatim@Continued\@empty 102 \let\sphinxVerbatim@Continues\@empty 103 \fi 104 \ifspx@opt@verbatimwrapslines 105 % fancyvrb's Verbatim puts each input line in (unbreakable) horizontal boxes. 106 % This customization wraps each line from the input in a \vtop, thus 107 % allowing it to wrap and display on two or more lines in the latex output. 108 % - The codeline counter will be increased only once. 109 % - The wrapped material will not break across pages, it is impossible 110 % to achieve this without extensive rewrite of fancyvrb. 111 % - The (not used in sphinx) obeytabs option to Verbatim is 112 % broken by this change (showtabs and tabspace work). 113 \let\sphinxVerbatimFormatLine\sphinxVerbatimFormatLineWrap 114 \let\FV@Space\spx@verbatim@space 115 % Allow breaks at special characters using \PYG... macros. 116 \sphinxbreaksatspecials 117 % Breaks at punctuation characters . , ; ? ! and / (needs catcode activation) 118 \fvset{codes*=\sphinxbreaksviaactive}% 119 \else % end of conditional code for wrapping long code lines 120 \let\sphinxVerbatimFormatLine\sphinxVerbatimFormatLineNoWrap 121 \fi 122 \let\FancyVerbFormatLine\sphinxFancyVerbFormatLine 123 % workaround to fancyvrb's check of \@currenvir 124 \let\VerbatimEnvironment\sphinxVerbatimEnvironment 125 % workaround to fancyvrb's check of current list depth 126 \def\@toodeep {\advance\@listdepth\@ne}% 127 % The list environment is needed to control perfectly the vertical space. 128 % Note: \OuterFrameSep used by framed.sty is later set to \topsep hence 0pt. 129 % - if caption: distance from last text baseline to caption baseline is 130 % A+(B-F)+\ht\strutbox, A = \abovecaptionskip (default 10pt), B = 131 % \baselineskip, F is the framed.sty \FrameHeightAdjust macro, default 6pt. 132 % Formula valid for F < 10pt. 133 % - distance of baseline of caption to top of frame is like for tables: 134 % \sphinxbelowcaptionspace (=0.5\baselineskip) 135 % - if no caption: distance of last text baseline to code frame is S+(B-F), 136 % with S = \sphinxverbatimtopskip (=\smallskip) 137 % - and distance from bottom of frame to next text baseline is 138 % \baselineskip+\parskip. 139 % The \trivlist is used to avoid possible "too deeply nested" error. 140 \itemsep \z@skip 141 \topsep \z@skip 142 \partopsep \z@skip 143 % trivlist will set \parsep to \parskip = zero 144 % \leftmargin will be set to zero by trivlist 145 \rightmargin\z@ 146 \parindent \z@% becomes \itemindent. Default zero, but perhaps overwritten. 147 \trivlist\item\relax 148 \ifsphinxverbatimwithminipage\spx@inframedtrue\fi 149 % use a minipage if we are already inside a framed environment 150 \ifspx@inframed\noindent\begin{minipage}{\linewidth}\fi 151 \ifx\sphinxVerbatimTitle\empty 152 \begin{tcolorbox}[breakable,toprule at break=0pt,bottomrule at break=0pt,pad at break*=2mm] 153 \else 154 % \show\sphinxVerbatimTitle 155 % \begin{codebox}{\sphinxLiteralBlockLabel \sphinxVerbatimTitle} 156 \captionsetup{margin=0pt,aboveskip=0pt,belowskip=0pt,justification=raggedright,singlelinecheck=false,font=white} 157 % \traceon 158\begin{tcolorbox}[breakable,,toprule at break=0pt,bottomrule at break=0pt,pad at break*=2mm,title={\sphinxVerbatimTitle}] 159 % \traceoff 160 \fi 161 % \MakeFramed {% adapted over from framed.sty's snugshade environment 162 % \advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize\@setminipage 163 % }% 164 % For grid placement from \strut's in \FancyVerbFormatLine 165 \lineskip\z@skip 166 % active comma should not be overwritten by \@noligs 167 \ifspx@opt@verbatimwrapslines 168 \let\verbatim@nolig@list \sphinx@verbatim@nolig@list 169 \fi 170 % will fetch its optional arguments if any 171 \OriginalVerbatim 172} 173{% 174 \endOriginalVerbatim 175 % \par\unskip\@minipagefalse\endMakeFramed % from framed.sty snugshade 176 \end{tcolorbox} 177 \ifspx@inframed\end{minipage}\fi 178 \global\let\sphinxLiteralBlockLabel\empty 179 \global\let\sphinxVerbatimTitle\empty 180 \endtrivlist 181} 182 183\def\theliteralblock{\arabic{part}.\arabic{chapter}.\arabic{literalblock}} 184\def\thefigure{\arabic{part}.\arabic{chapter}.\arabic{figure}} 185