I would like to control numbered, unnumbered section through the \setcounter{secnumdepth}{5} command.
My requirement by default all the section heading should be unnumbered. So i will set default value \setcounter{secnumdepth}{0}. If i give the \numbered command all the head levels should be numbered. So i should create the command \newcommand{\numbered}{\setcounter{secnumdepth}{5}}
Another requirement is section levels should be uppercase. So i am using the command \MakeUppercase command.
But the problem is raised below mentioned cases (BOOKMARK LINK NOT WORKING):
At the same time i am using two commands \setcounter{secnumdepth}{0} and \MakeUppercase, pdfbookmark is not working.
Case 1. \setcounter{secnumdepth}{0} and \MakeUppercase both commands used - pdfbookmark is not working.
Case 2. \setcounter{secnumdepth}{5} and \MakeUppercase both commands used - pdfbookmark is working.
I don't know first case is not worked. second case is worked. Please advice.
Alternatively i am using below mentioned pdfstring command. But this command is not working
\pdfstringdefDisableCommands{%
\let\MakeUppercase\relax%
}
MWE:
\documentclass{article}
\usepackage{hyperref}
\usepackage{lipsum}
\setcounter{secnumdepth}{0}
\makeatletter
\newcommand{\numbered}{\setcounter{secnumdepth}{5}}
\makeatother
\hypersetup{%
colorlinks,%
linkcolor=black,%
citecolor=gray,%
bookmarks=true,
bookmarksopen=true,%
bookmarksnumbered=true,%
pdftitle={\@mytitle},%
pdfauthor={Maria Luisa Di Vona},%
pdfkeywords={},%
pdfsubject={}%
}
\pdfstringdefDisableCommands{%
\let\MakeUppercase\relax%
}
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-2.8ex}%
{8.25pt}%
{\raggedright\MakeUppercase}}
\makeatother
\begin{document}
\title{This is the sample title}
\author{Steven}
\maketitle
\section{This is the sample section one $\alpha$}
\lipsum[1-5]
\section{Second section}
\lipsum[5-10]
\section{Second section}
\lipsum[4]
\lipsum[5]
\section{This is the sample section two}
\lipsum[1]
\lipsum[1]
\end{document}
\MakeUppercasebe made into\@firstofonerather than\relaxin\pdfstringdefDisableCommands? – egreg Oct 08 '15 at 20:39\@firstofone, but the curly braces will be removed anyway. – Heiko Oberdiek Oct 08 '15 at 20:58\tracingmacrossettings are just leftovers from testing. If\tracingmacrosis larger than zero, then the macro expansions are written to the.logfile. – Heiko Oberdiek Oct 09 '15 at 16:03\expandafterremove the\elsebranch and the\fitoken, thus that\MakeUppercaseand\@firstofonewill see the intended argument as their argument{#1}. – Heiko Oberdiek Oct 09 '15 at 16:04