Hyperref che va in strano errore

  • Creatore
    Topic
  • #34915
    Up
    0
    Down
    ::


    Ho ridefinito tableofcontents e section, e creato ‘intermedia’:
    `\documentclass[a4paper,twoside,10pt]{article}
    %% Inizio definizione lingua
    \usepackage[italian]{babel}
    \usepackage{ucs}
    \usepackage[T1]{fontenc}
    \usepackage[utf8x]{inputenc}
    %% Fine definizione lingua
    \usepackage{helvet}
    \renewcommand{\rmdefault}{\sfdefault}
    \renewcommand\familydefault{\sfdefault}
    % Formato dei titoli di sezione (bold, sans-serif)
    \usepackage[bf,sf]{titlesec}

    \usepackage{xtab}
    \usepackage{lastpage}
    \usepackage[unicode, colorlinks=true, linkcolor=black, pdfstartview=FitH]{hyperref}
    %% Estensione dei file grafici
    \DeclareGraphicsExtensions{.pdf, .gif, .jpg, .jpeg, .png}
    \usepackage[a4paper, left=1.5cm, right=1.5cm, bottom=2cm, top=2cm ,bindingoffset=0cm]{geometry}

    \makeatletter
    \renewcommand\tableofcontents{%
    \if@twocolumn
    \@restonecoltrue\onecolumn
    \else
    \@restonecolfalse
    \fi
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }
    \renewcommand\section{%
    \if@openright
    \cleardoublepage
    \else
    \clearpage
    \fi
    \thispagestyle{fancy}%
    \if@twocolumn
    \onecolumn
    \@tempswatrue
    \else
    \@tempswafalse
    \fi
    \null\vfil\vspace{30mm}
    \secdef\@Intermedia\@spart}

    \def\@Intermedia[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
    \refstepcounter{section}%
    \addcontentsline{toc}{section}{\thesection\hspace{1em}#1}%
    \else
    \addcontentsline{toc}{section}{#1}%
    \fi
    \markboth{}{}%
    {\raggedleft
    \interlinepenalty \@M
    \normalfont
    \ifnum \c@secnumdepth >-2\relax
    \Huge \bfseries \nobreakspace\thesection
    \par
    \vskip 20\p@
    \fi
    \LARGE \bfseries #2\par}%
    \@endpart}
    \def\@spart#1{%
    {\centering
    \interlinepenalty \@M
    \normalfont
    \Huge \bfseries #1\par}%
    \@endpart}
    \def\@endpart{\vfil\newpage
    \if@tempswa
    \twocolumn
    \fi}
    \makeatother

    \begin{document}

    \section{Generalità}`
    Il documento intero viene regolarmente compilato solo se dopo ‘\begin{document}’ c’è almeno una lettera unicode prima della prima ‘section’. Ad esempio, se la prima sezione è ‘Generalità’, ottengo il seguente errore:`./SSCM_-_U0250—0307B_IT_C66.tex:264: Token not allowed in a PDF string (Unicode),(hyperref) removing `\begingroup' on input line 264. Token not allowed in a PDF string (Unicode),(hyperref) removing `\begingroup'
    ./SSCM_-_U0250—0307B_IT_C66.tex:264: Token not allowed in a PDF string (Unicode),(hyperref) removing `\-command' on input line 264. Token not allowed in a PDF string (Unicode),(hyperref) removing `\-command'
    ./SSCM_-_U0250—0307B_IT_C66.tex:264: Token not allowed in a PDF string (Unicode),(hyperref) removing `\utf@viii@undeferr' on input line 264. Token not allowed in a PDF string (Unicode),(hyperref) removing `\utf@viii@undeferr'
    ./SSCM_-_U0250—0307B_IT_C66.tex:264: Token not allowed in a PDF string (Unicode),(hyperref) removing `\endgroup' on input line 264. Token not allowed in a PDF string (Unicode),(hyperref) removing `\endgroup'`Si accettano commenti anche malevoli… ma sarebbero più graditi i suggerimenti per capire dove sta l’inghippo…

Visualizzazione 2 filoni di risposte
  • Autore
    Risposte
    • #34916
      Up
      0
      Down
      ::

      Ho ridefinito tableofcontents e section, e creato ‘intermedia’:
      `\documentclass[a4paper,twoside,10pt]{article}
      %% Inizio definizione lingua
      \usepackage[italian]{babel}
      \usepackage{ucs}
      \usepackage[T1]{fontenc}
      \usepackage[utf8x]{inputenc}
      %% Fine definizione lingua
      \usepackage{helvet}
      \renewcommand{\rmdefault}{\sfdefault}
      \renewcommand\familydefault{\sfdefault}
      % Formato dei titoli di sezione (bold, sans-serif)
      \usepackage[bf,sf]{titlesec}

      \usepackage{xtab}
      \usepackage{lastpage}
      \usepackage[unicode, colorlinks=true, linkcolor=black, pdfstartview=FitH]{hyperref}
      %% Estensione dei file grafici
      \DeclareGraphicsExtensions{.pdf, .gif, .jpg, .jpeg, .png}
      \usepackage[a4paper, left=1.5cm, right=1.5cm, bottom=2cm, top=2cm ,bindingoffset=0cm]{geometry}

      \makeatletter
      \renewcommand\tableofcontents{%
      \if@twocolumn
      \@restonecoltrue\onecolumn
      \else
      \@restonecolfalse
      \fi
      \@starttoc{toc}%
      \if@restonecol\twocolumn\fi
      }
      \renewcommand\section{%
      \if@openright
      \cleardoublepage
      \else
      \clearpage
      \fi
      \thispagestyle{fancy}%
      \if@twocolumn
      \onecolumn
      \@tempswatrue
      \else
      \@tempswafalse
      \fi
      \null\vfil\vspace{30mm}
      \secdef\@Intermedia\@spart}

      \def\@Intermedia[#1]#2{%
      \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{section}%
      \addcontentsline{toc}{section}{\thesection\hspace{1em}#1}%
      \else
      \addcontentsline{toc}{section}{#1}%
      \fi
      \markboth{}{}%
      {\raggedleft
      \interlinepenalty \@M
      \normalfont
      \ifnum \c@secnumdepth >-2\relax
      \Huge \bfseries \nobreakspace\thesection
      \par
      \vskip 20\p@
      \fi
      \LARGE \bfseries #2\par}%
      \@endpart}
      \def\@spart#1{%
      {\centering
      \interlinepenalty \@M
      \normalfont
      \Huge \bfseries #1\par}%
      \@endpart}
      \def\@endpart{\vfil\newpage
      \if@tempswa
      \twocolumn
      \fi}
      \makeatother

      \begin{document}

      \section{Generalità}`
      Il documento intero viene regolarmente compilato solo se dopo ‘\begin{document}’ c’è almeno una lettera unicode prima della prima ‘section’. Ad esempio, se la prima sezione è ‘Generalità’, ottengo il seguente errore:`./SSCM_-_U0250—0307B_IT_C66.tex:264: Token not allowed in a PDF string (Unicode),(hyperref) removing `\begingroup' on input line 264. Token not allowed in a PDF string (Unicode),(hyperref) removing `\begingroup'
      ./SSCM_-_U0250—0307B_IT_C66.tex:264: Token not allowed in a PDF string (Unicode),(hyperref) removing `\-command' on input line 264. Token not allowed in a PDF string (Unicode),(hyperref) removing `\-command'
      ./SSCM_-_U0250—0307B_IT_C66.tex:264: Token not allowed in a PDF string (Unicode),(hyperref) removing `\utf@viii@undeferr' on input line 264. Token not allowed in a PDF string (Unicode),(hyperref) removing `\utf@viii@undeferr'
      ./SSCM_-_U0250—0307B_IT_C66.tex:264: Token not allowed in a PDF string (Unicode),(hyperref) removing `\endgroup' on input line 264. Token not allowed in a PDF string (Unicode),(hyperref) removing `\endgroup'`Si accettano commenti anche malevoli… ma sarebbero più graditi i suggerimenti per capire dove sta l’inghippo…

      Non è una buona idea ridefinire \section prima di caricare hyperref; né dopo, se è per quello. Tanto più se prima metti di mezzo titlesec.

      Ne avevamo già discusso in febbraio, adesso capisco il problema: quella ridefinizione non può funzionare perché appunto non tiene conto di hyperref. E con ucs e utf8x di mezzo, ci sono centinaia di cose che fanno andare in malora la compilazione.

      Tra l’altro, a che ti serve la chiamata di titlesec per cambiare il font dei titoli di sezione quando già li stampi in nero e senza grazie, visto che il font base è Helvetica?

      Ultima ramanzina. 🙂 Non può funzionare nemmeno se chiami \thispagestyle{fancy} e non carichi fancyhdr.

      Se poi dopo il \makeatletter metti anche
      `\@ifundefined{if@openright}{\newif\if@openright}{}`
      puoi davvero usare il codice con la classe article.

      Riassumendo: togliendo titlesec, chiamando fancyhdr e aggiungendo quel codice, avrai un paio di avvisi, ma nessun errore.

      Ciao
      Enrico

    • #34917
      Up
      0
      Down
      ::

      Non è una buona idea ridefinire \section prima di caricare hyperref; né dopo, se è per quello. Tanto più se prima metti di mezzo titlesec.

      Ne avevamo già discusso in febbraio, adesso capisco il problema: quella ridefinizione non può funzionare perché appunto non tiene conto di hyperref. E con ucs e utf8x di mezzo, ci sono centinaia di cose che fanno andare in malora la compilazione.

      Tra l’altro, a che ti serve la chiamata di titlesec per cambiare il font dei titoli di sezione quando già li stampi in nero e senza grazie, visto che il font base è Helvetica?

      Ultima ramanzina. 🙂 Non può funzionare nemmeno se chiami \thispagestyle{fancy} e non carichi fancyhdr.

      Se poi dopo il \makeatletter metti anche
      `\@ifundefined{if@openright}{\newif\if@openright}{}`
      puoi davvero usare il codice con la classe article.

      Riassumendo: togliendo titlesec, chiamando fancyhdr e aggiungendo quel codice, avrai un paio di avvisi, ma nessun errore.

      Ciao
      Enrico

      Nobile Maestro, non funziona…
      Ottengo i seguenti errori:`./test_intermedia.tex:109: Token not allowed in a PDF string (Unicode),(hyperref) removing `\begingroup' on input line 109. Token not allowed in a PDF string (Unicode),(hyperref) removing `\begingroup'
      ./test_intermedia.tex:109: Token not allowed in a PDF string (Unicode),(hyperref) removing `\-command' on input line 109. Token not allowed in a PDF string (Unicode),(hyperref) removing `\-command'
      ./test_intermedia.tex:109: Token not allowed in a PDF string (Unicode),(hyperref) removing `\utf@viii@undeferr' on input line 109. Token not allowed in a PDF string (Unicode),(hyperref) removing `\utf@viii@undeferr'
      ./test_intermedia.tex:109: Token not allowed in a PDF string (Unicode),(hyperref) removing `\endgroup' on input line 109. Token not allowed in a PDF string (Unicode),(hyperref) removing `\endgroup'`
      La riga incriminata è quella dove c’è ‘\section{Generalità}’

      Questo è il file che sto cercando di compilare:
      `\documentclass[a4paper,twoside,10pt]{article}
      \usepackage[italian]{babel}
      \usepackage{ucs}
      \usepackage[T1]{fontenc}
      \usepackage[utf8x]{inputenc}
      \usepackage{helvet}
      \renewcommand{\rmdefault}{\sfdefault}
      \renewcommand\familydefault{\sfdefault}
      \usepackage[final]{graphicx}
      \usepackage{lastpage}
      \usepackage{fancyhdr}
      \usepackage[unicode, colorlinks=true, linkcolor=black, pdfstartview=FitH]{hyperref}
      \DeclareGraphicsExtensions{.pdf, .gif, .jpg, .jpeg, .png}
      \usepackage[a4paper, left=1.5cm, right=1.5cm, bottom=2cm, top=2cm ,bindingoffset=0cm]{geometry}
      \pagestyle{fancy}
      \fancyhf{}
      \fancyhead[RE,LO]{\includegraphics{Mastro_Intestazione}}
      \fancyhead[C]{}
      \fancyhead[RO,LE]{\rightmark}
      \fancyfoot[RE,LO]{\includegraphics{Mastro_PieDiPagina}}
      \fancyfoot[C]{}
      \fancyfoot[RO,LE]{\thepage/\pageref{LastPage}}
      \renewcommand{\headrulewidth}{0.4pt}
      \renewcommand{\footrulewidth}{0.4pt}
      \setlength{\headheight}{45pt}

      \makeatletter
      \@ifundefined{if@openright}{\newif\if@openright}{}
      \renewcommand\tableofcontents{%
      \if@twocolumn
      \@restonecoltrue\onecolumn
      \else
      \@restonecolfalse
      \fi
      \@starttoc{toc}%
      \if@restonecol\twocolumn\fi
      }
      \renewcommand\section{%
      \if@openright
      \cleardoublepage
      \else
      \clearpage
      \fi
      \thispagestyle{fancy}%
      \if@twocolumn
      \onecolumn
      \@tempswatrue
      \else
      \@tempswafalse
      \fi
      \null\vfil\vspace{30mm}
      \secdef\@Intermedia\@spart}

      \def\@Intermedia[#1]#2{%
      \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{section}%
      \addcontentsline{toc}{section}{\thesection\hspace{1em}#1}%
      \else
      \addcontentsline{toc}{section}{#1}%
      \fi
      \markboth{}{}%
      {\raggedleft
      \interlinepenalty \@M
      \normalfont
      \ifnum \c@secnumdepth >-2\relax
      \Huge \bfseries \nobreakspace\thesection
      \par
      \vskip 20\p@
      \fi
      \LARGE \bfseries #2\par}%
      \@endpart}
      \def\@spart#1{%
      {\centering
      \interlinepenalty \@M
      \normalfont
      \Huge \bfseries #1\par}%
      \@endpart}
      \def\@endpart{\vfil\newpage
      \if@tempswa
      \twocolumn
      \fi}
      \makeatother

      \begin{document}

      \section{Generalità}

      Bla bla bla

      \end{document}
      `

    • #34918
      Up
      0
      Down
      ::

      Nobile Maestro, non funziona…
      Ottengo i seguenti errori:`./test_intermedia.tex:109: Token not allowed in a PDF string (Unicode),(hyperref) removing `\begingroup' on input line 109. Token not allowed in a PDF string (Unicode),(hyperref) removing `\begingroup'
      ./test_intermedia.tex:109: Token not allowed in a PDF string (Unicode),(hyperref) removing `\-command' on input line 109. Token not allowed in a PDF string (Unicode),(hyperref) removing `\-command'
      ./test_intermedia.tex:109: Token not allowed in a PDF string (Unicode),(hyperref) removing `\utf@viii@undeferr' on input line 109. Token not allowed in a PDF string (Unicode),(hyperref) removing `\utf@viii@undeferr'
      ./test_intermedia.tex:109: Token not allowed in a PDF string (Unicode),(hyperref) removing `\endgroup' on input line 109. Token not allowed in a PDF string (Unicode),(hyperref) removing `\endgroup'`
      La riga incriminata è quella dove c’è ‘\section{Generalità}’

      È un problema dovuto al pacchetto ucs. Prendere o lasciare; non si presenta se si evita di chiamarlo e si dà l’opzione utf8 a inputenc. In ogni caso non sono errori, ma semplici avvisi.

      Ciao
      Enrico

Visualizzazione 2 filoni di risposte
  • Devi essere connesso per rispondere a questo topic.

Go to top