0

I tried different solutions but without result I have configured arara on texstudio to be able to use the nomenclature package.

\usepackage[refpage,intoc,italian]{nomencl}
\makenomenclature
\renewcommand{\pagedeclaration}[1]{.\quad #1}


\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
    \item[\bfseries
    \ifstrequal{#1}{P}{Physics Constants}{%
        \ifstrequal{#1}{N}{Number Sets}{%
            \ifstrequal{#1}{O}{Other Symbols}{}}}%
    ]}

I was going to build a nomenclature of my personal commands contained in a mydef.tex file

from the file mydef.tex I can pick up the useful definitions to the nomenclature, that I am going to insert in a nomen.tex file such as:

\mbox{}

\nomenclature[O]{$\ui$}{Velocità $i$-esima }
\nomenclature[O]{$\uij$}{....... $i$-esima }
\nomenclature[O]{$\uijj$}{....... $i$-esima }

enter image description here

I would like to include in the nomenclature not only the meaning of the symbol, but also the text of the command I use to represent it on latex, that is, I would like it to be:

\mbox{}

\nomenclature[O]{$\ui$}{Velocità $i$-esima \verb|\ui|}
\nomenclature[O]{$\uij$}{....... $i$-esima \verb|\uij|}
\nomenclature[O]{$\uijj$}{....... $i$-esima  \verb|\uijj|}

it would be possible ? do you have any suggestions?

thanks

---------------------UPDATE-----------------------------

minimal example :

% arara: pdflatex: { draft: true }
% arara: nomencl: {style: 'nomencl.ist'}
% arara: pdflatex: { synctex: true }    
% arara: pdflatex: { synctex: true }   
\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{array,booktabs}% http://ctan.org/pkg/{array,booktabs}
\usepackage{xparse}
%%---------------------nomenclatura-----------------------------------
\usepackage[refpage,intoc,italian]{nomencl}
\makenomenclature
\renewcommand{\pagedeclaration}[1]{.\quad #1}


\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
    \item[\bfseries
    \ifstrequal{#1}{P}{Physics Constants}{%
        \ifstrequal{#1}{N}{Number Sets}{%
            \ifstrequal{#1}{O}{Other Symbols}{}}}%
    ]}
% This will add the units
%----------------------------------------------------------------------
\newcommand{\nomunit}[1]{%
    \renewcommand{\nomentryend}{\hspace*{\fill}#1}}
\newrobustcmd{\cs}[1]{\texttt{\textbackslash #1}}
%%-------------fine nomenc--------------------------------------------

\newcommand{\ui}{\ensuremath{u_{i}}} %% u i-esima scalare
\newcommand{\uij}{\ensuremath{u_{i,j}}} %% u j-esima scalare
\newcommand{\uijj}{\ensuremath{u_{i,jj}}} %% u j-esima scalare
%\input{mydef}
\begin{document}

    \begin{table}[h]
        \renewcommand{\arraystretch}{1.75}
        \begin{tabular}{lcccc}
            \hline
            Simbolo & Significato & Comando\\ \hline

            \ui & Velocità $i$-esima & \verb|\ui|  \\
            \uij & Velocità $i$-esima & \verb|\uij|  \\
            \uijj & Velocità $i$-esima & \verb|\uijj|  \\
            \hline

        \end{tabular}
    \end{table}

    This is a minimal working example and I would like to write: \\

    $\ui$ \qquad Velocità $i$-esima \qquad \verb|\ui|
    \\
    \printnomenclature

    \mbox{}
    \nomenclature[O]{$\ui$}{Velocità $i$-esima \cs{\ui}}
    \nomenclature[O]{$\uij$}{Velocità $i$-esima }
    \nomenclature[O]{$\uijj$}{Velocità $i$-esima} 
    \printnomenclature

\end{document}

enter image description here enter image description here

  • You can't use \verb in the argument of another command. You have to use something like \string\ui but make sure both don't get expanded, so more like \noexpand\string\noexpand\ui (but I'm not sure what exactly and won't look into it without a proper MWE). – Skillmon Nov 19 '18 at 17:53
  • 1
    You'd be better off defining a command that typesets the control sequence name. For example, \newrobustcmd{\cs}[1]{\texttt{\textbackslash #1}} and then replace \verb|\ui| with \cs{ui}. (Aside from not being able to use verbatim in an argument, | is also a makeindex special character.) – Nicola Talbot Nov 19 '18 at 18:09
  • @NicolaTalbot I entered the command but the result is not the desired one. I added a minimal example – Antonio Nov 19 '18 at 18:32
2

You should use \cs like this: \cs{ui} and not \cs{\ui}, I've also included a slightly different implementation of \cs that gives a correct looking backslash:

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{array,booktabs}% http://ctan.org/pkg/{array,booktabs}
\usepackage{xparse}
%%---------------------nomenclatura-----------------------------------
\usepackage[refpage,intoc,italian]{nomencl}
\makenomenclature
\renewcommand{\pagedeclaration}[1]{.\quad #1}


\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
    \item[\bfseries
    \ifstrequal{#1}{P}{Physics Constants}{%
        \ifstrequal{#1}{N}{Number Sets}{%
            \ifstrequal{#1}{O}{Other Symbols}{}}}%
    ]}
% This will add the units
%----------------------------------------------------------------------
\newcommand{\nomunit}[1]{%
    \renewcommand{\nomentryend}{\hspace*{\fill}#1}}
\makeatletter
% quick and dirty method to get the correct backslash
\edef\mybackslash{\expandafter\@gobble\string\\}
\makeatother
\newrobustcmd{\cs}[1]{\texttt{\mybackslash #1}}
%%-------------fine nomenc--------------------------------------------

\newcommand{\ui}{\ensuremath{u_{i}}} %% u i-esima scalare
\newcommand{\uij}{\ensuremath{u_{i,j}}} %% u j-esima scalare
\newcommand{\uijj}{\ensuremath{u_{i,jj}}} %% u j-esima scalare
%\input{mydef}
\begin{document}

    \begin{table}[h]
        \renewcommand{\arraystretch}{1.75}
        \begin{tabular}{lcccc}
            \hline
            Simbolo & Significato & Comando\\ \hline

            \ui & Velocità $i$-esima & \verb|\ui|  \\
            \uij & Velocità $i$-esima & \verb|\uij|  \\
            \uijj & Velocità $i$-esima & \verb|\uijj|  \\
            \hline

        \end{tabular}
    \end{table}

    This is a minimal working example and I would like to write: \\

    $\ui$ \qquad Velocità $i$-esima \qquad \verb|\ui|
    \\
    \printnomenclature

    \mbox{}
    \nomenclature[O]{$\ui$}{Velocità $i$-esima \cs{ui}}
    \nomenclature[O]{$\uij$}{Velocità $i$-esima \cs{uij}}
    \nomenclature[O]{$\uijj$}{Velocità $i$-esima \cs{uijj}} 
    \printnomenclature

\end{document}

enter image description here

  • I think that to make a list of commands is more appropriate to use the table. I find the final result seen from the point of view of the nomenclature redundant. thanks for the precious help and very useful to understand how to handle certain commands – Antonio Nov 19 '18 at 20:09

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.