The example below causes an error:
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
l.7 \path (0,0) node {a\\a
};
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\centering
%\begin{minipage}{1em}
\begin{tikzpicture}
\path (0,0) node {a\\a};
\end{tikzpicture}
%\end{minipage}
\end{document}
If I comment out the \centering, get rid of the linebreak, or un-
comment the minipage environemnt then all goes well.
I take it you cannot use the tikzpicture environment in any context.
If so, is this documented somewhere?
Please note that I'm using pgfCVS2009-06-02_TDS and don't have an easy
way to re-install pgf 2.00.
Thanks in advance.
Regards,
Marc van Dongen
> The example below causes an error:
>
> ! LaTeX Error: Something's wrong--perhaps a missing \item.
> See the LaTeX manual or LaTeX Companion for explanation.
> Type H <return> for immediate help.
> l.7 \path (0,0) node {a\\a
> };
>
> \documentclass{minimal}
> \usepackage{tikz}
> \begin{document}
> \centering
> %\begin{minipage}{1em}
> \begin{tikzpicture}
> \path (0,0) node {a\\a};
\path (0,0) node {\tabular{@{}c@{}}a\\a\endtabular};
Herbert
Thanks Herbert. Of course I could do this:-) but I want to know why
the \centering isn't allowed. Alos, creating the tabular is a bit of
an overhead.
Thanks again.
Regards,
Marc van Dongen
(speaking as a non-tikz-user) the problem presumably comes from
\centering's redefinition of \\
the \parbox would also restore some standard \\, iirc.
--
Robin Fairbairns, Cambridge
> (speaking as a non-tikz-user) the problem presumably comes from
> \centering's redefinition of \\
>
> the \parbox would also restore some standard \\, iirc.
Thanks! It may also explain why \\ didn't work with \centering.
Regards,
Marc van Dongen
With the latest CVS you can say
\path (0,0) node [align=center] {a\\a};
or something like
\path (0,0) node [text width=0.5cm, text centered] {a\\a};
which is (a bit) cleaner and works with any surrounding \centering
Regards
Mark
> With the latest CVS you can say
>
> \path (0,0) node [align=center] {a\\a};
>
> or something like
>
> \path (0,0) node [text width=0.5cm, text centered] {a\\a};
>
> which is (a bit) cleaner and works with any surrounding \centering
Thanks. I was aware of this, but this centers the text at the node
level. I want to cent the whole tikzpicture (inside a figure):
\begin{figure}
\centering
\begin{tikzpicture}
...
\end{tikzpicture}
\end{figure}
Regards,
Marc van Dongen
Which is still possible if you the keys in the way I suggested (or
with left alignment or ragged text) as internally they set up the
definition of \\ so that error you were getting does not occur.
Regards
Mark
Mark
OK. Thanks I misunderstood.
It does work, but I don't think this is a clean solution as you need
to specify the 'text width' attribute, which has to be 'large enough'
but which you don't (want to) know (or think about) in a general
picture. For example, even the change of a font's point size at the
document level may break a hard-coded 'text width'. Having a node with
an actual size (as opposed to the 'text width' size) is clearly
better.
Regards,
Marc van Dongen
The align key (which uses \halign internally) shown in my original
example allows you to do similar things without specifying the width
of the node.
Regards
Mark
Hope this
> The align key (which uses \halign internally) shown in my original
> example allows you to do similar things without specifying the width
> of the node.
Thanks, but doesn't for me. The following gives me an error. If I
uncomment the commented line I don't.
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\centering
\begin{tikzpicture}
\draw (0,0) node[text centered
%,text width=0.5cm
] {a\\a};
\end{tikzpicture}
\end{document}
Note that without the \centering and without uncommenting the comment,
the tikzpicture isn't centred, which is what I want: I need to have
the tikzpicture centred, regardless of its size.
Regards,
Marc van Dongen
So, the following doesn't work for you?
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\centering
\begin{tikzpicture}
\draw (0,0) node[align=center] {a\\a};
\end{tikzpicture}
\end{document}
regards
Mark
Nope. This works but the 'text centered' is different from the
'align=center'.
Regards,
Marc van Dongen
Well, perhaps you could provide an example, because to my eyes the
following pairs look identical (CVS pgf version)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\centering
\begin{tikzpicture}
\draw (0,0) node[draw, align=center] {a\\a};
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) node[draw, text width=width("a"),text centered] {a\
\a};
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) node[draw, align=center] {some text\\here};
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) node[draw, text width=width("some text"),text
centered] {some text\\here};
> > Nope. This works but the 'text centered' is different from the
> > 'align=center'.
> Well, perhaps you could provide an example, because to my eyes the
> following pairs look identical (CVS pgf version)
[snip]
I think you misunderstood my reply.
In the thread, I gave an example that had 'text centered' in it and I
wrote there was a problem with it. Next, you provided an example with
'align=center' in it and wrote 'So, the following doesn't work for
you?'.
When I replied "This works but the 'text centered' is different from
the 'align=center'" I did not mean that the resulting pictures were
different (I never checked them). Indeed, I wanted to let you know
that *the* 'text centered' was different from *the* 'align=center'. I
wrote this because I didn't get the 'So' in your reply.
Regards,
Marc van Dongen