Il primo punto non ho nessun problema.
il secondo l’ho risolto. Metto un esempio completo e non ci pensiamo più. Ho aggiunto un po’ di csname endcsname e un expandafter e ho utilizzato \comando. L’indice analitico sembra tutto ok. Prova.
`
\documentclass{scrreprt}
\usepackage{amssymb,makeidx}
\usepackage{classicthesis-ldpkg}
\usepackage[beramono,eulermath]{classicthesis}
\DeclareRobustCommand*{\pacchetto}[1]{{\normalfont\ttfamily#1}%
\index{Pacchetto!#1@\texttt{#1}}%
\index{#1@\texttt{#1}}}
\DeclareRobustCommand*{\comando}[1]{\lstinline!\\#1!%
\index{Comando!#1@\texttt{\textbackslash#1}}%
\index{#1@\texttt{\hspace*{-1.2ex}\textbackslash#1}}}
\newcommand\forlstinline[1]{\scantokens{\lstinline!#1!}\unskip}
\newcommand{\X}[1]{$\csname#1\endcsname$&\comando{#1}\hspace*{1ex}}
\newcommand{\SC}[1]{\csname#1\endcsname&\comando{#1}\hspace*{1ex}}
\newcommand{\W}[2]{$\csname#1\endcsname{#2}$&
\comando{#1}\kern.15em\forlstinline{{#2}}\hspace*{1ex}}
\newcommand{\Y}[1]{$\expandafter\big\csname#1\endcsname$ &\comando{#1}}
\newcommand{\A}[1]{#1&\texttt{\forlstinline#1}\hspace*{1ex}}
\newcommand{\B}[2]{#1#2&\texttt{\forlstinline#1{} #2}\hspace*{1ex}}
\newsavebox{\symbbox}
\newenvironment{symbols}[1]%
{\medskip
\renewcommand{\arraystretch}{1.1}
\begin{lrbox}{\symbbox}
\begin{tabular}{@{}#1@{}}}%
{\end{tabular}\end{lrbox}\makebox[\textwidth][c]{\usebox{\symbbox}}\par\medskip}
\IfFileExists{mathrsfs.sty}
{\RequirePackage{mathrsfs}\let\MathRSFS\mathscr\let\mathscr\relax}{}
\IfFileExists{amssymb.sty}
{\let\noAMS\relax \RequirePackage{amssymb}}
{\def\noAMS{\endinput}\RequirePackage{latexsym}}
\IfFileExists{eucal.sty}
{\RequirePackage[mathscr]{eucal}}
{\IfFileExists{euscript.sty}
{\RequirePackage{euscript}}{}}
\IfFileExists{amsbsy.sty}
{\RequirePackage{amsbsy}}{}
\lstset{moretexcs={mathnormal,mathcal}}
\DeclareSymbolFont{ltxsymbols}{OMS}{cmsy}{m}{n}
\DeclareSymbolFontAlphabet{\ltxmathcal}{ltxsymbols}
\makeindex
\begin{document}
\begin{table}[tb]
\caption{Font matematici.}
\begin{symbols}{@{}*3l@{}}
\toprule
Esempio & Comando & Pacchetto richiesto \\
\midrule
$\mathit{ABCdef}$ & \comando{mathit}\lstinline!{ABCdef}! & \\
$\mathbf{ABCdef}$ & \comando{mathbf}\lstinline!{ABCdef}! & \\
$\mathrm{ABCdef}$ & \comando{mathrm}\lstinline!{ABCdef}! & \\
$\mathtt{ABCdef}$ & \comando{mathtt}\lstinline!{ABCdef}! & \\
$\mathsf{ABCdef}$ & \comando{mathsf}\lstinline!{ABCdef}! & \\
$\mathnormal{ABCdef}$ & \comando{mathnormal}\lstinline!{ABCdef}! & \\
$\ltxmathcal{ABC}$ & \comando{mathcal}\lstinline!{ABC}! & \\
\ifx\MathRSFS\undefined\else
$\MathRSFS{ABC}$ & \comando{mathscr}\lstinline!{ABC}! &\pacchetto{mathrsfs} \\
\fi
\ifx\EuScript\undefined\else
$\EuScript{ABC}$ & \comando{mathcal}\lstinline!{ABC}! &\pacchetto{eucal} \\
$\mathfrak{ABCdef}$ & \comando{mathfrak}\lstinline!{ABCdef}! &\pacchetto{eufrak} \\
\fi
$\mathbb{ABC}$ & \comando{mathbb}\lstinline!{ABC}! &\pacchetto{amssymb} \\
\bottomrule
\end{symbols}
\end{table}
\begin{table}
\caption{Prova.}
\begin{symbols}{*3{cl}}
\W{bar}{a} & \W{hat}{a} & \W{tilde}{a} \\
\X{alpha} & \X{iota} & \X{varrho} \\
\Y{lgroup} & \Y{lmoustache} & \Y{arrowvert} \\
\SC{dag} & \SC{S} & \SC{copyright} \\
\end{symbols}
\end{table}
\printindex
\end{document}`
Io se fossi in te toglierei
\index{Pacchetto!#1@\texttt{#1}} sotto \pacchetto e \index{Comando!#1@\texttt{\textbackslash#1}} sotto \comando.
Con le voci esageri un po’ troppo ❗
Ciao
Andrea