Latex renewcommand not working properly

Why is this not working:

documentclass[a4paper,10pt]{article}
usepackage{a4wide}
usepackage[T1]{fontenc}
usepackage[portuguese]{babel}
usepackage[latin1]{inputenc}
usepackage{indentfirst}
usepackage{listings}
usepackage{fancyhdr}
usepackage{url}
usepackage[compat2,a4paper,left=25mm,right=25mm,bottom=15mm,top=20mm]{geometry}
usepackage{color}
usepackage[colorlinks]{hyperref}
usepackage[pdftex]{graphicx}

renewcommand{headrulewidth}{0.4pt}
renewcommand{footrulewidth}{0.4pt}

pagestyle{fancy}

fancyhead[L]{small Laboratórios de Informática III}
fancyhead[R]{small Projecto 1 (Linguagem textsf{C})}

lstset{
    basicstyle=ttfamilyfootnotesize,
    showstringspaces=false,
    frame=single,
    tabsize=4,
    breaklines=true,

}

definecolor{Section1}{rgb}{0.09,0.21,0.36}
definecolor{Section2}{rgb}{0.21,0.37,0.56}
definecolor{Section3}{rgb}{0.30,0.50,0.74}

hypersetup{
    bookmarks=false,
    linkcolor=red,
    urlcolor=cyan,
}

renewcommand{section}[1]{texorpdfstring{color{green}#1}{#1}}

parskip=6pt

begin{document}

begin{titlepage}

begin{center}

includegraphics[width=5cm]{./logo.jpg}[1cm]

textsc{LARGE Universidade do Minho}[1cm]

textsc{large Licenciatura em Engenharia InformáticaLaboratórios de Informática III}[1.5cm]

rule{linewidth}{0.5mm}[0.4cm]

huge{textbf{textsc{Relatório do Projecto 1 (Linguagem C)}}}

rule{linewidth}{0.5mm}

vfill

begin{tabular}{c c}

    includegraphics[width=3.5cm]{./nuno.jpg} & includegraphics[width=3.5cm]{./ricardo.jpg} 

    textsc{large{Nuno Mendes (51161)}} & textsc{large{Ricardo Amaral (48404)}} 

end{tabular}

vfill

large{today}

end{center}

end{titlepage}

tableofcontents

newpage

section{Introdução}

Lorem ipsum...

newpage

appendix

section{color{Section1}Diagrama das Estruturas de Dados}

begin{center}
includegraphics[width=16cm]{./Diagrama.pdf}
end{center}

end{document}

! LaTeX Error: Something's wrong--perhaps a missing item.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

                                               l.2 ...rline {1}color

{green}Teste}{3}{section.1}

How can I make it work properly?


You should try to condense your code down to a minimal example, then either you're getting to your error yourself or we can help you a bit better. i don't think that all the code above is necessary.


I inserted your renewcommand into one of my LaTeX files and it worked fine, though I have questions about your aesthetic choices. This leads me to think that your error arises when you use the redefined macro. But your question does not really show us that. Or, that the error occurs before your use of the macro but that LaTeX doesn't notice until it executes the macro and fails.

EDIT: OK, I copied your text into an empty document and tried to process it. My system complained about

lstset{
basicstyle=ttfamilyfootnotesize,
showstringspaces=false,
frame=single,
tabsize=4,
breaklines=true,

}

which does not finish properly -- the comma in breaklines=true, is misplaced. However once I had removed that comma and commented out the includegraphics statements the file was processed without complaint. This reinforces my belief that the error is not in our renewcommand macro.


This was for a project report already delivered and I'm not going to bother with it anymore, at least for now cause I have more important things to deal with at the moment.

I "fixed" it by using newcommand instead and created my own commands to replace section, subsection and it was basically a case of find/replace. It's not the best solution as I like to use whatever is there already and configure it accordingly, but it will do for now...

I'll revisit this problem in the future if I need too. I appreciate everyone's input.

链接地址: http://www.djcxy.com/p/33454.html

上一篇: 乳胶:每章参考书目

下一篇: 乳胶再生命令不能正常工作