To answer the subsidiary question:
The picture doesn't center as it is too wide:
Overfull \hbox (122.19116pt too wide) in paragraph at lines 93--94
in such cases TeX always puts the additional material into the right margin.
It is also too long:
LaTeX Warning: Float too large for page by 42.29073pt on input line 95.
Assuming that you don't mind it overlapping the nominal top and side margins, you can raise it by 45pt and insert (essentially arbitrary) negative space either side so that its effective width is less than text width. (I also switched your font choice as I don't have Calibri)
\documentclass[10pt]{article}
\usepackage{fontspec}
\setmainfont{cmunrm.otf}
%\setmainfont{Calibri}
\usepackage{tikz}
\usetikzlibrary{fit,calc,trees,patterns,positioning,backgrounds,arrows,chains,shapes.geometric,%
decorations.pathreplacing,decorations.pathmorphing,shapes,%
matrix,shapes.symbols}
\tikzset{
join/.style={},
myarrow/.style={->, thick,shorten >=1pt},
mybox/.style={draw,rounded corners, minimum height=.7cm,align=center,node distance=1em},
leftright/.style={outer sep=0,inner sep=0,text width=2cm,draw,align=center,node distance=0em,minimum height=3em},
mainnode/.style={very thick,fill=red!10},
spannodes/.style={text depth=-5pt,draw,inner sep=0em,outer sep=0,minimum height=1.5em,align=center,node distance=0em}
}
\begin{document}
\thispagestyle{empty}
\begin{figure}
\centering
\vspace*{-45pt}
\hspace*{-3cm}\begin{tikzpicture}[remember picture]
% THE MAIN CHAIN THAT GOES STRAIGHT DOWN
\node(placeholder){};
\node[minimum height=1cm,minimum width=5cm,below=of placeholder.south,join] (lexicon) {};
\node[mainnode,mybox,below=2cm of lexicon.south,join] (nuclearpredication) {nuclear predication};
\node[mybox,below=of nuclearpredication,join] (lev1) {π\textsubscript{1} σ\textsubscript{1}};
\node[mainnode,mybox,below=of lev1,join] (corepredication) {core predication};
\node[mybox,below=of corepredication] (lev2) {π\textsubscript{2} σ\textsubscript{2}};
\node[mybox,below=of lev2] (syntacticfunctions) {syntactic functions};
\node[mainnode,mybox,below=of syntacticfunctions] (extendedpredication) {extended predication};
\node[mybox,below=of extendedpredication] (lev3) {π\textsubscript{3} σ\textsubscript{3}};
\node[mainnode,mybox,below=of lev3] (proposition) {proposition};
\node[mybox,below=of proposition] (lev4) {π\textsubscript{4} σ\textsubscript{4}};
\node[mybox,below=of lev4] (pragmaticfunctions) {pragmatic functions};
\node[mainnode,mybox,below=of pragmaticfunctions] (clausestructure) {clause structure};
\node[mybox,below=of clausestructure] (expressionrules) {\textsc{Expression Rules}\\\\form\\order\\prosody};
\node[mainnode,mybox,below=of expressionrules] (linguisticexpression) {\textsc{Linguistic Expression}};
% THE SECONDARY CHAIN LEFT AND RIGHT
% LEFT OF
\node[xshift=-1.5cm,leftright,left=of lexicon.south] (basicpredicates) {basic predicates};
\node[leftright,left=of basicpredicates] (derivedpredicates) {derived predicates};
\node[xshift=-2em,leftright,left=of derivedpredicates] (predicateformation) {predicate\\formation};
\node[fit={(derivedpredicates.west) (basicpredicates.east)},spannodes,below=of basicpredicates.south] at ($(derivedpredicates.south)!0.5!(basicpredicates.south)$) (predicateframes) {\textsc{Predicate Frames}};
% RIGHT OF
\node[xshift=1.5cm,leftright,right=of lexicon.south] (basicterms) {basic\\terms};
\node[leftright,right=of basicterms] (derivedterms) {derived\\terms};
\node[xshift=2em,leftright,right=of derivedterms] (termformation) {term\\formation};
\node[fit={(basicterms.west) (derivedterms.east)},spannodes,below=of basicterms] at ($(basicterms.south)!0.5!(derivedterms.south)$) (terms) {\textsc{Terms}};
\node [draw, very thick,inner sep=0,fit={
(lexicon) (derivedpredicates) (predicateframes) (derivedterms) (terms) (placeholder)
},label=\textsc{Fund}] (fund){};
\begin{pgfonlayer}{background}
\node [draw=blue!100,anchor=south,dashed,fill=green!10,inner sep=0pt,fit={
(basicpredicates) (basicterms) (lexicon)
},label=\textsc{Lexicon}] {};
\end{pgfonlayer}{background}
%\node[above=2cm of basicterms.east] (rightcorner) {};
%\draw[label=Lexicon] (basicpredicates.south west) rectangle (rightcorner);
% Connect the Lines
\draw[red] (derivedpredicates.north) -| ++(0,1.2) -| (derivedterms.north);
\draw[blue] (predicateformation.north) -| ++(0,1.4) -| (termformation.north);
\draw[blue] (predicateformation.east) to (derivedpredicates);
\draw[blue] (predicateformation.south) -| ++(0,-.3) -| (predicateframes.west);
\draw[blue] (termformation.west) to (derivedterms.east);
% Draw Arrows
\draw[myarrow] (fund.south) to (nuclearpredication.north);
\draw[myarrow] (nuclearpredication.south) to (lev1.north);
\draw[myarrow] (lev1.south) to (corepredication.north);
\draw[myarrow] (corepredication.south) to (lev2.north);
\draw[myarrow] (lev2.south) to (syntacticfunctions.north);
\draw[myarrow] (syntacticfunctions.south) to (extendedpredication.north);
\draw[myarrow] (extendedpredication.south) to (lev3.north);
\draw[myarrow] (lev3.south) to (proposition.north);
\draw[myarrow] (proposition.south) to (lev4.north);
\draw[myarrow] (lev4.south) to (pragmaticfunctions.north);
\draw[myarrow] (pragmaticfunctions.south) to (clausestructure.north);
\draw[myarrow] (clausestructure.south) to (expressionrules.north);
\draw[myarrow] (expressionrules.south) to (linguisticexpression.north);
\end{tikzpicture}\hspace*{-3cm}
\caption{Functional Grammar Model Overview}
\end{figure}
\end{document}
As Jake said in the comments, this is probably beyond the realm of writing directly into TikZ, but you could probably still get it done, if you wanted some other benefits of TikZ. (e.g., fonts that are consistent with the rest of the documents)
If you already have some software to generate 3D plots separately from LaTeX (such as MATLAB or Mathematica), then you might want to look to see if there’s a library that translates drawing code from that software into TikZ that you can embed in LaTeX. Here are some examples of what I mean:
Doing it externally and importing TikZ is almost certainly the way to go. It will be a lot easier than trying to get it to get something that’s workable, and the end result will be a lot better.
Below I’ve given a brief example of how I do it, using R. It’s unlikely that you’ll be able to use my solution directly, but it might give you an idea of what I mean, and perhaps give you a pointer in the right direction.
A personal example:
I often use R to do my plots (R is a free, statistical programming language), and R has a useful module for exporting to TikZ. This TikZ code can then be loaded into a LaTeX document and compiled as normal.
The R package for 3d contour plots is contour3d
, and here’s an example from that documentation page:
require(tikzDevice)
require("misc3d")
tikz("isosurface.tex", width=5, height=5)
##################################################################
# #
# Example from the R documentation #
# http://rss.acs.unt.edu/Rdoc/library/misc3d/html/contour3d.html #
# #
##################################################################
nmix3 <- function(x, y, z, m, s) {
0.4 * dnorm(x, m, s) * dnorm(y, m, s) * dnorm(z, m, s) +
0.3 * dnorm(x, -m, s) * dnorm(y, -m, s) * dnorm(z, -m, s) +
0.3 * dnorm(x, m, s) * dnorm(y, -1.5 * m, s) * dnorm(z, m, s)
}
f <- function(x,y,z) nmix3(x,y,z,.5,.5)
g <- function(n = 40, k = 5, alo = 0.1, ahi = 0.5, cmap = heat.colors) {
th <- seq(0.05, 0.2, len = k)
col <- rev(cmap(length(th)))
al <- seq(alo, ahi, len = length(th))
x <- seq(-2, 2, len=n)
contour3d(f,th,x,x,x,color=col,alpha=al)
rgl.bg(col="white")
}
g(40,5)
gs <- function(n = 40, k = 5, cmap = heat.colors, ...) {
th <- seq(0.05, 0.2, len = k)
col <- rev(cmap(length(th)))
x <- seq(-2, 2, len=n)
m <- function(x,y,z) x > .25 | y < -.3
contour3d(f,th,x,x,x,color=col, mask = m, engine = "standard",
scale = FALSE, ...)
rgl.bg(col="white")
}
gs(40, 5, screen=list(z = 130, x = -80), color2 = "lightgray", cmap=rainbow)
### End of example
dev.off()
Most of that is just drawing the 3D plot, but the lines at the top and bottom turn the plotted output into TikZ, which gets saved to isosurface.tex
.
Once I've run that script, I can \input
that document into another LaTeX file. For example:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\input{isosurface.tex}
\end{document}
This is what it looks like:
and the rendering in the LaTeX-ed PDF is remarkably faithful to the original:
Some caveats:
- For a 3D plot, the associated TikZ file is ~big. Approximately 2.2 MB, which is an order of magnitude bigger than most TikZ documents.
- It will slow you down. That smallish example added ~30 seconds to the compile time. If you have more complicated ones, or lots of them, expect to get significantly slowed down. You might want to look at using something like TikZ’s
externalize
library to avoid the worst performance hit.
If you want to use R, then questions about how to draw your plots are off-topic at this Stack Exchange, but you might want to head over to Cross Validated if you need a hand. Topics about R and data visualisation are more on-topic there.
Best Answer
FreeCAD has the option to export to SVG.
Once you have an SVG version of your drawing, you can proceed by either:
\includegraphics
to import it in your LaTeX document, optionally using TikZ to annotate it or further enrich the contents.svg2tikz
to convert the SVG to TikZ codeFor manipulation of the SVG itself, I recommend the free Inkscape program.