When using \centering
this way, I get everything centered, text and figure:
\documentclass[varwidth=true,border=5pt]{standalone}
\usepackage{color}
\usepackage{tikz}
\newenvironment{nscenter}
{\parskip=0pt\par\nopagebreak\centering}
{\par\noindent\ignorespacesafterend}
\begin{document}
\centering
Generations lived here alone. Strangers this is our home! Strangers, this is our home! Welcome strangers, stay as our friends. The beauty of our land never ends.
\newline
\newline
\begin{tikzpicture}
\filldraw[orange] (-1.2, 0) circle (5pt);
\filldraw[blue] ( 2 , 0) circle (2pt);
\draw ( 0 , 0) ellipse (2 and 1);
\end{tikzpicture}
\end{document}
But this does not center anything:
\documentclass[varwidth=true,border=5pt]{standalone}
\usepackage{color}
\usepackage{tikz}
\newenvironment{nscenter}
{\parskip=0pt\par\nopagebreak\centering}
{\par\noindent\ignorespacesafterend}
\begin{document}
Generations lived here alone. Strangers this is our home! Strangers, this is our home! Welcome strangers, stay as our friends. The beauty of our land never ends. \newline
\newline
\begin{tikzpicture}
\centering
\filldraw[orange] (-1.2, 0) circle (5pt);
\filldraw[blue] ( 2 , 0) circle (2pt);
\draw ( 0 , 0) ellipse (2 and 1);
\end{tikzpicture}
\end{document}
The use of domain \begin{center}...\end{center}
did not work either. Have gone through the other questions: scaling, \par
, frames, etc., …nothing.
Update: I try to center the figure with respect to the rest of the text in the simplest way possible (minimal latex writing and packages imported).
Note: Text on the document updated, just to show that the text means a width larger than the image.
Best Answer
The most natural way to centre something is the
center
environmentOr with standalone:
or with standalone and the longer text in the edited question