Graphics with lots of points are always a challenge for TeX-based processors.
However, I am convinced that both memory and time limitations can be tackled to "reasonable" degree (i.e. to reduced pain).
There are two solutions which should both be considered:
to increase TeX's memory (or to circumvent the limitations of pdflatex).
to reduce the number of times the graphic is being processed by TeX (compile once, use often).
While the comments to your question already indicate some solutions concerning (2.), you may need more input for (1.). In fact, I believe that (1.) is the more pressing issue which cannot easily be solved by (2.).
Concerning (1.), I know that one solution works pretty well: to increase the limits. The pgfplots manual contains details instructions for both windows and linux how to enlarge the memory limits. I consider that to be a mandatory step for you - and invite you to follow the link above and read chapter "6 Memory and Speed Considerations" in the pgfplots
manual. The chapter contains readily deployable configuration examples. It might be that switching to lualatex instead of the conventional tools (pdflatex or latex/dvips) might also solve the memory problem (I do not know).
Concerning (2.), you can use the standalone
package (this site contains a lot of examples). This should work with any of your packages. However, if you use matlab2tikz
, I find the TikZ library external
very useful here - I tailored it to convert each figure to a separate pdf without changing the original document. Note that matlab2tikz
uses pgfplots
, so the link mentioned above might be very useful (it also contains a brief description of this automatic image externalization).
I believe that the steps above should help.
But there are always cases where one might also want to know about alternatives.
Here are some of them. I did not post them directly because I have the impression that you may already have an existing workflow and they may not fit - but perhaps you are interested in my experiences anyway:
a) you could try to implement (selected) figures directly in TeX. I did so by means of pgfplots
which is quite powerful. I like the fact that I could define document-wide consistent styles and that the single documents are, well, often easier to read than autogenerated code. In fact, once I started using pgfplots instead of matlab, I found that both simpler to maintain (.tex files instead of .m files) and prettier. I dropped all of my matlab scripts eventually and used only pgfplots in the end.
b) if your vector graphics are too large, you may want to consider using bitmap graphics and use TeX to overlay axis descriptions over the bitmap. pgfplots
comes with its \addplot graphics
and \addplot3 graphics
commands to streamline the process. You can also post feature requests to Nico Schloemer (author of matlab2tikz) - perhaps he is willing to add automatic bitmap conversion with overlay axes. Details for such an approach can be found in the aforementioned pgfplots
manual (including application examples). Bitmap graphics have the advantage that they render much faster in all viewers - and for surface plots, it does not matter anyway.
I agree with the comments that you'd need a scripting language to extract the information from your existing documents, but once you have the information in a database you can use the datatool package to generate a report for a particular patient. For the type of information you want to save, I wouldn't recommend using csv as I would find that tricky to edit (but that depends on what you use to edit it). Here's how it might look in csv form (using | as a separator as you requested):
Patient Number|Name|Surname|DoB|Sex|Address|Phone|History|Past History|Personal History|Family History|Examination|Diagnosis|Treatment
0001|Joe|Bloggs|1974-12-06|Male|"1 The Street, The Town"|0123456|Joe's patient history here|Joe's past history here|Joe's personal history|Joe's family history|Joe's examination|\begin{enumerate}\item Joe's diagnosis\end{enumerate}|\begin{enumerate}\item Joe's treatment\end{enumerate}
0002|Jane|Doe|1970-05-18|Female|"2 The Street, The Town"|0123457|Mary's patient history here|Mary's past history here|Mary's personal history|Mary's family history|Mary's examination|\begin{enumerate}\item Mary's diagnosis\end{enumerate}|\begin{enumerate}\item Mary's treatment\end{enumerate}
0003|John|Smith|1969-01-20|Male|"3 The Street, The Town"|01234568|John's patient history here|John's past history here|John's personal history|John's family history|John's examination|\begin{enumerate}\item John's diagnosis\end{enumerate}|\begin{enumerate}\item John's treatment\end{enumerate}
Alternatively, the same information can be store in a .tex file using the datatool format:
\DTLnewdb{patients}
% Patient Joe Bloggs (patient number 0001)
\DTLnewrow*{patients}
\DTLnewdbentry*{patients}{Patient Number}{0001}
\DTLnewdbentry*{patients}{Name}{Joe}
\DTLnewdbentry*{patients}{Surname}{Bloggs}
\DTLnewdbentry*{patients}{DoB}{1974-12-06}
\DTLnewdbentry*{patients}{Sex}{Male}
\DTLnewdbentry*{patients}{Address}{1 The Street, The Town}
\DTLnewdbentry*{patients}{Phone}{0123456}
\DTLnewdbentry*{patients}{History}{Joe's patient history here}
\DTLnewdbentry*{patients}{Past History}{Joe's past history here}
\DTLnewdbentry*{patients}{Personal History}{Joe's personal history}
\DTLnewdbentry*{patients}{Family History}{Joe's family history}
\DTLnewdbentry*{patients}{Examination}{Joe's examination}
\DTLnewdbentry*{patients}{Diagnosis}
{%
\begin{enumerate}
\item Joe's diagnosis
\end{enumerate}
}
\DTLnewdbentry*{patients}{Treatment}
{%
\begin{enumerate}
\item Joe's treatment
\end{enumerate}
}
% Patient Jane Doe (patient number 0002)
\DTLnewrow*{patients}
\DTLnewdbentry*{patients}{Patient Number}{0002}
\DTLnewdbentry*{patients}{Name}{Jane}
\DTLnewdbentry*{patients}{Surname}{Doe}
\DTLnewdbentry*{patients}{DoB}{1970-05-18}
\DTLnewdbentry*{patients}{Sex}{Female}
\DTLnewdbentry*{patients}{Address}{2 The Street, The Town}
\DTLnewdbentry*{patients}{Phone}{0123457}
\DTLnewdbentry*{patients}{History}{Mary's patient history here}
\DTLnewdbentry*{patients}{Past History}{Mary's past history here}
\DTLnewdbentry*{patients}{Personal History}{Mary's personal history}
\DTLnewdbentry*{patients}{Family History}{Mary's family history}
\DTLnewdbentry*{patients}{Examination}{Mary's examination}
\DTLnewdbentry*{patients}{Diagnosis}
{%
\begin{enumerate}
\item Mary's diagnosis
\end{enumerate}
}
\DTLnewdbentry*{patients}{Treatment}
{%
\begin{enumerate}
\item Mary's treatment
\end{enumerate}
}
% Patient John Smith (patient number 0003)
\DTLnewrow*{patients}
\DTLnewdbentry*{patients}{Patient Number}{0003}
\DTLnewdbentry*{patients}{Name}{John}
\DTLnewdbentry*{patients}{Surname}{Smith}
\DTLnewdbentry*{patients}{DoB}{1969-01-20}
\DTLnewdbentry*{patients}{Sex}{Male}
\DTLnewdbentry*{patients}{Address}{3 The Street, The Town}
\DTLnewdbentry*{patients}{Phone}{0123458}
\DTLnewdbentry*{patients}{History}{John's patient history here}
\DTLnewdbentry*{patients}{Past History}{John's past history here}
\DTLnewdbentry*{patients}{Personal History}{John's personal history}
\DTLnewdbentry*{patients}{Family History}{John's family history}
\DTLnewdbentry*{patients}{Examination}{John's examination}
\DTLnewdbentry*{patients}{Diagnosis}
{%
\begin{enumerate}
\item John's diagnosis
\end{enumerate}
}
\DTLnewdbentry*{patients}{Treatment}
{%
\begin{enumerate}
\item John's treatment
\end{enumerate}
}
You can access a particular patient like this:
\documentclass{scrartcl}
\usepackage{datatool}
% load from csv file:
%\DTLsetseparator{|}
%\DTLloaddb{patients}{patients.csv}
% or load from .tex file:
\input{patients}
\title{Consultation Report}
\author{}
\newcommand*{\getdetails}[1]{%
\dtlgetentryfromcurrentrow{\patientdetails}{\dtlcolumnindex{patients}{#1}}%
\patientdetails
}
\begin{document}
\maketitle
% fetch patient's details (patient number 0002)
\dtlgetrowforvalue{patients}{\dtlcolumnindex{patients}{Patient Number}}{0002}%
\begin{tabular}{ll}
Name: & \getdetails{Name} \getdetails{Surname}\\
DoB: & \getdetails{DoB}\\
Sex: & \getdetails{Sex}\\
Address: & \getdetails{Address}\\
Phone: & \getdetails{Phone}
\end{tabular}
\section*{Clinical details}
\subsection*{Present history}
\getdetails{History}
\subsection*{Past History}
\getdetails{Past History}
\subsection*{Personal history}
\getdetails{Personal History}
\subsection*{Family history }
\getdetails{Family History}
\subsection*{Examination}
\getdetails{Examination}
\section*{Diagnosis}
\getdetails{Diagnosis}
\section*{Rx}
\getdetails{Treatment}
\begin{flushright}
My Name \\
{\footnotesize Qualification
}\\
{\footnotesize designation}\\
{\footnotesize Ph: }
\par\end{flushright}{\footnotesize \par}
\end{document}
Best Answer
Here's an example document using Python, with both code and output.
To use this example, you will need Python. Anaconda is a good option for this sort of thing. You also need the
pythontex
package. It's in TeX Live. It can also be installed manually; download the latest version from GitHub, extract, then run the Python installer in thepythontex
directory.To compile the document, you will need to use a three-step compile when Python code needs to be executed. Run LaTeX, then
pythontex
, then LaTeX again. For example, for a fileanalysis.tex
, you might usepdflatex -interaction=nonstopmode analysis.tex
pythontex analysis.tex
pdflatex -interaction=nonstopmode analysis.tex
When
pythontex
is properly installed, you should have a wrapper/symlink that allows it to be run from the command line.Data file
data.csv
:TeX source:
Output: