我想修饰行为,\paragraph
但我的代码中有些问题,有人能帮助我吗?
\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage[table]{xcolor}
\usepackage{sectsty}
\renewcommand{\thesection}{{\color{black!80} \thechapter-\arabic{section}}}
\makeatletter
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}{-3.25ex \@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}{\sffamily\normalsize\bfseries}}
\makeatother
\chapterfont{\thispagestyle{empty}\huge \sffamily \color{blue!50!black}\raggedleft}
\sectionfont{\sffamily}
\subsectionfont{\fcolorbox{blue!80}{blue!80}{\phantom{XXX}} \color{blue}\sffamily}
\subsubsectionfont{\fcolorbox{green!80}{green!80}{\phantom{XX}}\phantom{X} \color{green!50!black}\sffamily}
\paragraphfont{\fcolorbox{red!50!black}{red!50!black}{\phantom{XXX}}\phantom{XXX} \color{white}\sffamily}
\begin{document}
\chapter{este capítulo}
cap
\section{en la sección}
escribiendo
\subsection{subsección}
mas todavia
\subsubsection{subsub}
y finalmente
\paragraph{que un párrafo}
no funciona
\end{document}
答案1
在使用该sectsty
包时,通常最好对\section
、\subsection
等进行重新定义前加载sectsty
并发出诸如\chapterfont
、\sectionfont
等指令。
另一个问题:在 的定义中\paragraphfont
,指令的\color{white}
作用是使字符串“que un párrafo”( 的参数\paragraph
)不可见。例如,将指令更改为\color{orange}
以验证此声明。
\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage[spanish]{babel}
\usepackage[table]{xcolor}
%\setcounter{secnumdepth}{4} % uncomment this, if desired
\renewcommand{\thesection}{%\color{black!80}
\thechapter-\arabic{section}}
\makeatletter
\renewcommand{\paragraph}{\@startsection{paragraph}%
{4}{\z@}{-3.25ex \@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}{\sffamily\normalsize\bfseries}}
\makeatother
\usepackage{sectsty}
\chapterfont{\thispagestyle{empty}\huge \sffamily \color{blue!50!black}\raggedleft}
\sectionfont{\sffamily}
\subsectionfont{\fcolorbox{blue!80}{blue!80}{\phantom{XXX}} \color{blue}\sffamily}
\subsubsectionfont{\fcolorbox{green!80}{green!80}{\phantom{XX}}\phantom{X} \color{green!50!black}\sffamily}
\paragraphfont{\fcolorbox{red!50!black}{red!50!black}{\phantom{XXX}}\phantom{XXX} \color{orange}\sffamily}
\begin{document}
\chapter{este capítulo}
cap
\section{en la sección}
escribiendo
\subsection{subsección}
mas todavia
\subsubsection{subsub}
y finalmente
\paragraph{que un párrafo}
ahora funciona bien
\end{document}