New info at the bottom!
Previous title: LyX "incomplete \iffalse"
Previous text:
I'm new to LyX and TeX in general, so this might be a very easy problem.
I had made a TikZ image as a figure in my document, and it worked fine. I wanted to add a caption, and learned that you have to put it in a float to do that, so I moved it into a float (I'm not completely sure what a float is, but I don't think that matters here; I put the TeX code inside a TeX code block inside a figure float). Suddenly, it doesn't work at all.
Trying to render a preview makes it say "The external program pdflatex finished with an error." I looked at the log, as it suggested, which says "! Incomplete \iffalse; all text was ignored after line 68." I opened the file in notepad++ and looked at line 68; here's the neighborhood of it:
65 \quotes_language english 66 \papercolumns 1 67 \papersides 1 68 \paperpagestyle default 69 \tracking_changes false 70 \output_changes false 71 \html_math_output 0I then tried ctrl-f for "iffalse" and got no results. I also tried a search for "if", and only found the words "different" and "specifications" used in my document body, as well as line 55 "\justification true"--so there isn't even an if statement anywhere in this thing to cause that error!
Apologies if this has already been asked. It seems there are a lot of "incomplete \iffalse" questions on here, but I don't know enough about TeX to know what applies to my situation; they all seem to say "incomplete \iffalse with \somefunctionidon'trecognise" and I'm not sure if any of these apply.
So, at the advice of user Torbjørn T., I looked at the code in the TeX preview panel in LyX itself (which I hadn't used before because it doesn't show line numbers; I hadn't realized it didn't just display the .lyx file) and found that the TikZ code had found its way into a caption block, so the full figure code reads
\begin{figure}
\caption{\begin{tikzpicture}
\draw [fill] (0,0) circle [radius=65mm];;
\draw [white, fill=white] (0,0) circle [radius=60mm];;
\draw [brown, fill=brown] (0,0) circle [radius=50mm];;
\draw [->, thick] (0,0) -- (50mm,0);
\node [below] at (25mm,0) {$a=50\si{mm}$};
\draw [<->, thick] (50mm,0) -- (60mm, 0);
\node [above] at (55mm, 0) {$b$};
\node [below] at (55mm, 0) {10mm};
\end{tikzpicture}}
\end{figure}
I cannot edit this in the TeX preview panel, and I'm not sure how to extricate the tikzpicture block from the \caption in LyX. Could someone explain how to do this?


.lyxfile. Hard to say why this happens, I can't think of any reason why atikzpictureshould work outside a float but not inside it. Can you reduce your file to the smallest possible document that demonstrates the error, and add the LaTeX code to your question? (You can find the LaTeX code in View --> Code Preview Pane, select Complete source on the right side of the panel, if it isn't chosen already. Grab everything from\documentclassto\end{document}.) – Torbjørn T. May 25 '18 at 14:58tikzpictureis a caption...? It's put it inside a\captionblock. I suspect this is what's causing the problem. – Hearth May 25 '18 at 15:34