3

I want to specialize sectoining in persian biditufte class. I use this code in report class but in biditufte-handout class I got an error.

\documentclass{report}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}

\definecolor{sec}{HTML}{DD5C14}
\definecolor{band}{HTML}{EE9C52}

\titleformat{\section}[hang]{\sffamily\Huge\bfseries}{}{0.5ex}%
  {\begin{minipage}{0.975\textwidth}%
  \noindent
  \color{band}%
  \llap{\vrule width\textwidth height1ex depth0ex\hskip0.75ex}%
  \textcolor{sec}{\unskip#1}%
  \hskip0.75ex%
  \rlap{\vrule width\textwidth height1ex depth0ex}%
\end{minipage}}[\smallskip]


\usepackage[Kashida]{xepersian}
\settextfont[Language=Default]{Persian Modern}
\setdigitfont{Persian Modern}

\begin{document}
\section[\rl{اولین هدر} ]{\rl{اولین\\  بخش}}

مقداری متن برای اولین بخش

\end{document}

Is there any solution to use titlesec in this class? if not what can I do to change all sectoins like above code?

thanks.

  • What did the error say? – jarauh Oct 24 '15 at 20:50
  • You could put \PassOptionsToPackage{explicit}{titlesec} before \documentclass but if the class is using titlesec in a way that is incompatible with that, you'd need egreg's approach. – cfr Oct 24 '15 at 21:38
3

The biditufte-handout class already loads titlesec without the explicit option, so you can't load it again with the option.

It's not a big problem: without the explicit option, the last mandatory argument to \titleformat can be either empty or a macro that takes an argument, which the section title will be passed to.

However, one has also to override the \titleformat instruction issued by the class, delaying the new one at begin document.

\documentclass{biditufte-handout}
\usepackage{xcolor}

\definecolor{sec}{HTML}{DD5C14}
\definecolor{band}{HTML}{EE9C52}

\newcommand{\dosection}[1]{%
  \begin{minipage}{0.975\textwidth}
  \noindent
  \color{band}%
  \llap{\vrule width\textwidth height1ex depth0ex\hskip0.75ex}%
  \textcolor{sec}{\unskip#1}%
  \hskip0.75ex
  \rlap{\vrule width\textwidth height1ex depth0ex}%
  \end{minipage}%
}

\AtBeginDocument{%
  \titleformat{\section}[hang]
    {\sffamily\Huge\bfseries}
    {}
    {0.5ex}
    {\dosection}
    [\smallskip]%
}

\usepackage[Kashida]{xepersian}
\settextfont[Language=Default]{Persian Modern}
\setdigitfont{Persian Modern}

\begin{document}
\section[\rl{اولین هدر} ]{\rl{اولین\\  بخش}}

مقداری متن برای اولین بخش

\end{document}

enter image description here

  • very nice! if I want to learn Tex & LaTex like you what should I do?! – hossein behboodi Oct 25 '15 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.