LaTeX Error: Something's wrong--perhaps a missing \item, but the item is there

1,185

The \flushleft is an error, because it is actually an artifact of the flushleft environment, which encloses ragged-right text set off from the running text with vertical spaces (at begin and end). If you want a command version, the command is \raggedright. (I presume it should go before the \includegraphics.)

How does it interact with \item? The flushleft definition uses a "trivial list" to get the vertical spacing of lists.

(This answer comes after the question was editied with revealing information.)

Share:
1,185

Related videos on Youtube

NioA
Author by

NioA

Updated on August 01, 2022

Comments

  • NioA
    NioA over 1 year

    I'm trying to write a list in an enumerate environment, but for some reason even if the code is (apparently) correct, Latex gives me the following error at the second line: "! LaTeX Error: Something's wrong--perhaps a missing \item."

    Point is, this the code;

    \begin{enumerate}
        \item La soluzione per $\theta$ da' la conferma che il moto si svolge su un piano;
        \item La soluzione per $\phi$ restituisce la conservazione della velocità aerolare;
        \item La soluzione per r è la nota equazione dell'ellisse.
    \end{enumerate}
    

    And it follows the rules that I've seen on basically every LaTeX manuals on the internet, this "missing \item" is clearly there. I also have already the \usepackage{enumitem} activated, I'd say is also pretty standard. Someone might say that I could just skip it, the problem is that if I compile the code, this is the only error I get; If I delete this whole part of the code, the same error shows up on the following "itemize" or "enumerate" environment and so on, and that basically would mean that I should get ride of every list of the document to make it work, which is not exactly doable in a thesis. Maybe the solution is pretty dumb, but really I can't wrap my head around it. Thank you in advance.

    EDIT: Ok, following your advices I tried to find the specific lines that are the sources of the problem and this is what I got

    \begin{figure}[h]
    \includegraphics[scale=0.5]{Potenziale.png} 
    \caption{potenziale}
    \flushleft
    \end{figure}
    \clearpage
    \newpage
    \begin{enumerate}
        \item La soluzione per $\theta$ da' la conferma che il moto si svolge su un piano;
        \item La soluzione per $\phi$ restituisce la conservazione della velocità aerolare;
        \item La soluzione per r è la nota equazione dell'ellisse.
    \end{enumerate}
    \end{document}
    

    Normally, between the \newpage command and the part that I wrote before there are something like 200 lines of code. Clearly you don't have the source image so I suppose the code can't be ported somewhere else, but this is the situation. I tried to delete the image linked and it works; I can go on without the pic anyway, so at least the problem is solved (though i'm still curious why an image in a totally different part of the document would resulte in a "missing \item" )

    • gigiair
      gigiair almost 3 years
      I composed a working example with your code (follow the link: ix.io/2Est) . Please compose one with the error you get.
    • Donald Arseneau
      Donald Arseneau almost 3 years
      My cloudy crystal ball says you are doing something that redefined the enumerate environment to take an argument. Also, carefully check the line number given in the error message!
    • David Carlisle
      David Carlisle almost 3 years
      There is no point in posting a working fragment and asking about an error in code you have not posted. Please edit the question so the example is a complete small document that shows the error.
    • David Carlisle
      David Carlisle almost 3 years
      start from a copy of your document, delete everything after the enumerate, delete everything before the enumerate that you can delete while still showing the error, the delete any \usepackage not used in the resulting small example, and post the resulting document here. Then someone can debug the error.
    • NioA
      NioA almost 3 years
      Yeah, you're right, I should've thought before that reporting the correct code would have been useless. I'm sorry, this is the first time I have a problem with LateX that I couldn't solve by myself.
    • barbara beeton
      barbara beeton almost 3 years
      I can't say whether it will fix the problem, but \newpage isn't needed (or wanted) after \clearpage, and it's also usually better to leave a blank line after a figure. Not relevant to problem: to insert a block of code here, leave a blank line, enter the code, then highlight the block with the mouse and click on the {} icon above the answer box.
    • campa
      campa almost 3 years
      @barbarabeeton Somehow it has to do with the stray \flushleft at the end of the figure environment, but I cannot really understand how exactly the error originates.
  • NioA
    NioA almost 3 years
    Forgot to mention it, the code worked just fine when I copied it and paste in a new tex file. This would normally lead to believe that the problem lies somewhere else, possibly right before/after the environment, but if that would be the case, then it would be an isolated mistake; instead, as I said before, if I delete totally this part of the code, the same error shows up on the next itemize/enumerate environment and so on. For reference, in the original document there's just a line of introduction before the posted code and there's nothign after (just the beginning of a new section).
  • Michel Janssens
    Michel Janssens almost 3 years
    What documentclass are you using?
  • NioA
    NioA almost 3 years
    Article. This piece of code comes from a thesis for a bachelor
  • Michel Janssens
    Michel Janssens almost 3 years
    There it should work as well. In e.g. standalone, this will not work. Can you post the (minimal) document that fails? In those document classes you can use it but you have to place it in a minipage (so that \LaTeX\ knows the width of the text). I will add it to the answer.
  • NioA
    NioA almost 3 years
    Well, I have no idea on how to do this. The entire document have more than 900 lines of code and the lines that cause the error are the one that I wrote before and as you have seen, copying and pasting single lines doesn't show any error at all.
  • NioA
    NioA almost 3 years
    Also, I tried to change the document class in both "report" and "standalone". In report the error shows up again, but not in standalone, at least with the code you added after the edit. I don't know how feasible it is to change the document class after writing 30 page of this thing but it might be a solution, even if by doing it latex gave me something like ten other errors, presumably because of the change. Thank you anyway, I might take this in consideration as a solution
  • Michel Janssens
    Michel Janssens almost 3 years
    Sorry, standalone is meant for very short images, not for big documents. I suggest you delete some of the 900 lines to come up with a smaller file. I cannot help you if I cannot reproduce the error.
  • Donald Arseneau
    Donald Arseneau almost 3 years
    @DavidCarlisle Should \@trivlist really assign \@newlisttrue globally but \@item sets \everypar locally to undo the setting..