![为什么 sectsty 包对于我来说不能和 \paragraph 一起使用?](https://linux22.com/image/360873/%E4%B8%BA%E4%BB%80%E4%B9%88%20sectsty%20%E5%8C%85%E5%AF%B9%E4%BA%8E%E6%88%91%E6%9D%A5%E8%AF%B4%E4%B8%8D%E8%83%BD%E5%92%8C%20%5Cparagraph%20%E4%B8%80%E8%B5%B7%E4%BD%BF%E7%94%A8%EF%BC%9F.png)
我想修饰行为,\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}