1

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=\ttfamily\footnotesize,
    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ática\\Laborató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?

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
  • How are your brackets? For every open, there's a close, and in the right place? That 'teste}' looks out of place to me. – mmr Apr 26 '10 at 15:23
  • I only use it like this on my code: \section{Teste} – rfgamaral Apr 26 '10 at 15:37
  • Updated question with "full" example. – rfgamaral Apr 26 '10 at 15:45
  • Your file is OK here. Please note that we can't run the file because it references graphics that are not on our systems. Please don't post example code that we can't run by simple copy&paste. You can simulate the graphics by saying `\vrule width 16cm height 5cm`. We won't print it out :-) If you have replaced the graphics in your test code, run it and please post the exact output you get in your question. – topskip Apr 26 '10 at 17:32
  • might be better to post on the superuser.com site :) – gatoatigrado Jun 27 '10 at 00:06
  • I think you might get more, better answers on tex.stackexchange.com – ocket8888 Feb 12 '16 at 00:55
  • I'm voting to close this question as off-topic because this should be posted on https://tex.stackexchange.com – Michael Ohlrogge Jul 26 '17 at 19:56

3 Answers3

1

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.

Habi
  • 1,157
  • 6
  • 18
  • changing your lstset to \lstset{ basicstyle=\ttfamily\footnotesize, showstringspaces=false, frame=single, tabsize=4, breaklines=true} makes it compilable for me... – Habi Apr 26 '10 at 17:32
  • well, i can't seem to be able to post code-snippets in comments. remove the blank line in your \lststed-block and then your document compiles for me (after I removed all the references to non-existent images and made sure my MacTex can work with your spanish chars...) – Habi Apr 26 '10 at 17:34
  • It doesn't compile for me and the empty line was a copy/paste problem, my code didn't have that empty line. But read my "answer" below. Thanks anyway. – rfgamaral Apr 26 '10 at 17:42
  • Although I agree with that, in a similar vein, you shouldn't answer the question unless you have an answer. I think this belongs in a comment. I still think the question should be shorter. – Daniel H Sep 07 '11 at 01:27
0

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=\ttfamily\footnotesize,
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.

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161
0

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.

rfgamaral
  • 16,546
  • 57
  • 163
  • 275