我试图让我的标题看起来像这样:
但到现在为止还没有成功。有人有什么想法可以让我的标题名称看起来像这样吗?我在 Tufte 图书环境中工作,并使用 pdfLaTeX 编译器。这是我的项目的最小代码:
\documentclass[justified,notoc,numbers]{tufte-handout}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{amsthm, mathtools, amsmath, amssymb}
\usepackage{mathrsfs, amsfonts}
\usepackage{booktabs}
\usepackage{units}
\usepackage{multicol}
\usepackage{titlesec}
\usepackage{bibentry}
\usepackage{xcolor}
\usepackage{color}
\usepackage{enumitem}
\usepackage{microtype}
\usepackage{listings}
\usepackage{theorem}
\usepackage{fancyhdr}
\usepackage[most]{tcolorbox}
%-----------FOR DEMO-----------
\usepackage{lipsum}
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}
\graphicspath{{graphics/}}
\usetikzlibrary{shadows}
\lstset{language=C}
%=======================================================
% FONT STYLE
%=======================================================
\renewcommand{\rmdefault}{ptm}
%=======================================================
% COUNTERS
%=======================================================
\newcounter{theexample}[section]
\newcounter{thedefinition}[section]
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
%=======================================================
% COLORS
%=======================================================
\definecolor{grey}{rgb}{0.9,0.9,0.9}
\definecolor{myColor}{rgb}{0.0, 0.5, 1.0}
%=======================================================
% TITLES & CAPTION OPTIONS
%=======================================================
\titleformat*{\section}{\huge\bfseries}
\titleformat*{\subsection}{\LARGE\bfseries}
\titleformat*{\subsubsection}{\large\bfseries}
\titleformat*{\paragraph}{\large\bfseries}
\titleformat*{\subparagraph}{\large\bfseries}
\titlespacing{\section}{0cm}{0cm}{0cm}[0cm]
\titlespacing{\subsection}{0pt}{*0}{*0}
\titlespacing{\subsubsection}{0pt}{*0}{*0}
\titlespacing{\paragraph}{0pt}{*2}{*2}
%=======================================================
% MY ENVIRONMENTS
%=======================================================
\newenvironment{demo}{\textit{Démonstration: }}{\hfill \faSquare}
\newtcbtheorem[no counter]{defn}{Définition \stepcounter{thedefinition}\thesection.\arabic{thedefinition}}{
breakable,
colback=white!80!gray,
colframe=black,
colbacktitle=black,
coltitle=white,
fonttitle=\bfseries,
enhanced,
attach boxed title to top left={xshift=5mm,yshift=-3mm,yshifttext=-1mm},
top = 3mm,
separator sign={\ -}
}{th}
\newcommand\remarque[1]{
\marginnote{\justify
\tikzpicture[baseline={(title.base)}]
\node[inner sep=5pt, align=justify,text width=4cm,drop shadow={shadow yshift=-5pt,shadow xshift=5pt,black},fill=white] (box) {\vskip5pt \nointerlineskip #1};
\node[right=5pt,inner sep=0pt,outer sep=5pt] (title) at (box.north west) {\scshape\normalsize\bfseries\color{myColor}Remarque};
\draw[draw=myColor,very thick](title.west)--(box.north west)--(box.south west)--(box.south east)--(box.north east)--(title.east);
\fill[myColor]([yshift=-10pt]box.north west)--+(-5pt,-5pt)--+(0pt,-10pt);
\endtikzpicture}
}
\newtcolorbox{exmp}[1][]{
breakable,
enhanced,
borderline west={2pt}{0pt}{myColor},
sharp corners,
boxrule=0pt,
fonttitle={\large\bfseries},
coltitle={black},
title= {\textcolor{myColor}{Exemple \stepcounter{theexample}\thesection.\arabic{theexample}:} #1\\},
attach title to upper,
right=0pt,
top=0pt,
bottom=0pt,
frame hidden,
colback=white!80!gray,
}
\newtcbtheorem[no counter]{summary}{en bref}{
breakable,
separator sign none,
breakable,
boxrule=0.6pt,
colback=white,
arc=0pt,
outer arc=0pt,
leftrule=0pt,
rightrule=0pt,
colframe=myColor,
colbacktitle=myColor,
fonttitle= \scshape \Large \bfseries,
coltitle={white},
left=0pt,
right=0pt,
fontupper=\footnotesize
}{the}
\title{test - tex.stackexchange.com}
\author[Author Name \& Firstname]{Author Name \& Firstname}
%=======================================================
% MACROS
%=======================================================
\newcommand{\etal}{\textit{et al}.}
\newcommand{\ie}{\textbf{\textit{i}.\textit{e}. }}
\newcommand{\eg}{\textbf{\textit{e}.\textit{g}. }}
\newcommand{\cfr}{\textit{cfr}. }
\newcommand{\dd}{\mathrm{d}} %For right d on integrals & derivatives
\newcommand{\X}{\mathcal{X}} %For probabilities notation
\newcommand{\Y}{\mathcal{Y}}
\newcommand{\Z}{\mathcal{Z}}
\renewcommand{\epsilon}{\varepsilon}
%=======================================================
% GEOMETRY
%=======================================================
\geometry{
left=15mm, % left margin
textwidth=140mm, % main text block
headsep=10mm,
headheight = 0mm,
marginparsep=7mm, % gutter between main text block and margin notes
marginparwidth=50mm, % width of margin notes
bottom = 1.5cm,
top = 1.7cm
}
%=======================================================
% HEADER/FOOTER
%=======================================================
\pagestyle{fancy}{
\fancyhf{}
\rhead{Author Name \& Firstname}
\lhead{\textsc{test} - tex.stackexchange.com}
\rfoot{Page \thepage}
}
%=======================================================
% CODE INSERTION OPTIONS
%=======================================================
\lstset{
basicstyle=\ttfamily,
mathescape=true,
frame=single,
captionpos = b
}
%=======================================================
% NEW WORD CAESURA
%=======================================================
\hyphenation{sto-cha-sti-ques}
%=======================================================
% DOCUMENT
%=======================================================
\begin{document}
%---------------------------------------------------------------
\begin{titlepage}
\fontfamily{pag}
\begin{center}
\noindent\begin{minipage}{1\textwidth}
\includegraphics[draft]{example-image}
\end{minipage}
\end{center}
\vfill
\centering
\colorbox{grey}{
\parbox[t]{1.2\textwidth}{
\parbox[t]{1.2\textwidth}{
\vspace{0.2cm}
\begin{center}
\fontsize{13pt}{0pt}\selectfont
\text{TEST - tex.stackexchange.com}\\
\fontsize{50pt}{0pt}\selectfont\bfseries
\vspace{0.3cm}\underline{Base project}\end{center} {\Huge2019}
\vspace{0.7cm}
}
}
}
\vfill
%------------------------------------------------
% Author name and information
%------------------------------------------------
\parbox[t]{1.2\textwidth}{
\raggedleft
\large
{\Large Author}\\[4pt]
University\\
\hfill\rule{0.2\linewidth}{1pt}
}
\end{titlepage}
%---------------------------------------------------------------
\renewcommand{\headrulewidth}{1pt}
\begin{fullwidth}
\lipsum[5]
\end{fullwidth}
\section{Chapter 1:}
\lipsum[2]
\lipsum[3]
\remarque{\lipsum[1]}
\begin{defn}{DEFINITION TITLE}{DEFLABEL}
\lipsum[4]
\end{defn}
\begin{exmp}
\lipsum[1]
\end{exmp}
\begin{summary}{}{}
\lipsum[1]
\end{summary}
\end{document}
答案1
tufte
对标题使用特殊定义,可以像这样调整:
\documentclass[justified,notoc,numbers]{tufte-handout}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{amsthm, mathtools, amsmath, amssymb}
\usepackage{mathrsfs, amsfonts}
\usepackage{booktabs}
\usepackage{units}
\usepackage{multicol}
\usepackage{titlesec}
\usepackage{bibentry}
\usepackage{xcolor}
\usepackage{color}
\usepackage{enumitem}
\usepackage{microtype}
\usepackage{listings}
\usepackage{theorem}
\usepackage{fancyhdr}
\usepackage[most]{tcolorbox}
\definecolor{grey}{rgb}{0.9,0.9,0.9}
\definecolor{myColor}{rgb}{0.0, 0.5, 1.0}
\makeatletter
\long\def\@caption#1[#2]#3{%
\par%
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup%
\@parboxrestore%
\if@minipage%
\@setminipage%
\fi%
\@tufte@caption@font\@tufte@caption@justification%
\colorbox{myColor}{\color{white}\noindent\csname fnum@#1\endcsname:} \ignorespaces#3\par%
%\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\makeatother
\begin{document}
\begin{figure}
\includegraphics{example-image}
\caption{text}
\end{figure}
\end{document}
答案2
像这样?
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[svgnames]{xcolor}
\usepackage{geometry}
\usepackage{caption}
\usepackage{graphicx}
\colorlet{shadecolor}{SteelBlue}
\DeclareCaptionFormat{shadelabel}{\colorbox{shadecolor}{\rule[-0.8ex]{0pt}{3ex}\,\color{white}#1~#2\kern -0.3em}~#3 }%
\captionsetup{format =shadelabel, font ={sf, bf}}
\begin{document}
\begin{figure}[!htb]
\centering
\includegraphics[scale=0.25]{cahier}
\caption{Le cahier d’une écolière}
\end{figure}
\end{document}