Ceci est une ancienne révision du document !
This is our fourth exploration of the topics at CTAN.ORG. We are up to the D section.
There are two languages here: Danish and Dutch. There are five items to do with data, and nine that work with various diagrams. There are also eight to do with DVI, those I will ignore. Under the main “diagram” topic are about 70 different packages: block diagrams, circuit diagrams, control diagrams, and others. There are packages to make knitting patterns and to make fingering diagrams for recorders. Since I do not know anything about knitting or playing a recorder, I will not demonstrate these packages. I have picked a few packages from one or two topics which I hope will be of interest to some readers. If there is a task you wish to do in Latex but are not sure how to do it, or how to use the relevant package, send me a note (rboardman@psmail.net) and tell me about it. I will do my best to sort out the problem.
The first package I will discuss is one that allows the import of CSV files directly into Latex documents. I often used CSV files to move data from application to application when I taught at college. CSV files are plain text (ASCII usually) files, usually generated either by a spreadsheet or database. A table of data is exported – with each row of the table as a separate line in the CSV file. Each field is separated from its neighbours with a comma. The package I have on my system is called csvsimple version 1.22 from 2021. There is an updated version called csvsimple-13. The more recent version is not part of the default installation on my machine, so I will demonstrate the earlier one. The author / maintainer says it is completely compatible.
There are only two commands needed to import a CSV file into a Latex document as a simple file. The first command is to “import” the package: \usepackage{csvsimple}. The second command imports the file: \csvautotabular{grades.csv}. You can see the result in the screenshot. By default, csvsimple assumes the first row has the field names. Notice the first row is formatted a little differently than the others.
The 46-page documentation contains several examples which are definitely worth review and study. The examples usually require one or more additional packages (tikz, csv-sorter, color, and others). The examples show how csvsimple can be used to generate graphs (or charts) and mail-merge letters. The documentation offers two alternatives to dealing with CSV files that do not have field names / data headers. It also shows how to convert files where the fields are separated not by commas but by some other character, usually quotation marks, and how to deal with data values that have commas in them.
Note: CSVsimple is not a spreadsheet or database. It does not sort data when importing. It takes the CSV data and converts it to a table. If you want to use more sophisticated methods and tools, then I suggest you investigate a set of packages called datatool.
The datatool package is a collection of eight interlinked packages. Datatool is the base package and it automatically loads the datatool-base. If any of the other six packages are loaded independently, they automatically load datatool which then loads datatool-base. Datatool-base itself automatically loads either datatool-fp or datatool-pgfmath, these provide the support for mathematically related commands. The documentation for datatool is 230 pages. There is an additional PDF which provides an annotated version of the code for datatool.
I am not going to review datatool in this issue. It is much too complex to describe in a few paragraphs. According to the documentation, “the datatool package provides a means of creating and loading databases.” The authors warn “Whilst Tex is an excellent typesetting language, it is not designed as a database management system, and attempting to use it as such is like trying to fasten a screw with a knife instead of a screwdriver – it can be done, but requires great care, and is more time consuming.” Bearing that in mind, if you are interested or need to link your Tex documents to databases I suggest you start with the online resource: dickimaw-books.com/faq/datatoolfaq.html.
I will move onto a couple of packages in the decorations topic.
The contour package is about twenty years old and has a specific function. It is also much easier to understand and easier to work with than datatool, its documentation is only fourteen pages, ten pages of which are annotated code. According to the author, contour “generates a colored contour around a given text in order to enable printing text over a background without the need of a color box around the text.”
Here (above) is the code controlling colorbox and contour. (The package color must be used.)
You can see the results in the image.
The other package I selected in the decoration topic is multicolrule. It has 24 pages of documentation; the last 14 pages are devoted to describing the implementation code. This package has a simple objective: to let users customize the appearance of the vertical rule(s) between columns in multi-column work. Some might ask why a user would want to do this. Multicolrule does not answer this question but makes this task possible if it is desired.
Here (next page, top right) is a bit of sample code.
In order to use the line-style=circles, the tikz package must be included, and included before multicolrule is included.
This package would be helpful if you were making a brochure with a tear-away panel. There is code to use many symbols and graphics instead of lines or dots as column dividers. The documentation is full of example column dividers, and the matching code. Samples of complete code are available in the downloaded zip. The code is in mcrule-examples.tex and the results can be seen in the mcrule-examples.pdf.
The last package I am going to discuss this time is smartdiagram, which is in the Diagram topic. The abstract of the documentation says “this package provides a way to easily draw diagrams in documents and presentations from a list of items thanks to TikZ.” As is often the case, the documentation includes a lengthy section of annotated implementation code. This section is useful if you wish to edit the macro code but not necessary if you wish to only use the macro.
Again from the documentation, “the basic command is \smartdiagram[type of diagram]{list of items}. The list of items should be comma-delimited.” There are 10 types of diagrams: circular, flow, descriptive, bubble, etc. There are several pages of example coding, along with illustrations of the results of each sample. If a user follows the examples and experiments with the code, they should learn a great deal about this very useful package. We do not have to rely on either presentation software or graphics software to generate these types of diagrams in our printed documents. Some simple coding in Latex will generate a PDF directly without having to use another piece of software and then import the graphic file. Modifications to the diagram can be made directly in the Latex code and a new revised PDF generated in a very short time.
As I hope is clear, I have only touched briefly on the capabilities of these packages. As I say every issue, read the documentation if you think one or more of these packages can be useful in your work. I also recommend reading novices-report.pdf by Dr. Nicola Talbot if you are getting started with Latex. If you are writing a thesis or other lengthy document in Latex, I recommend thesis-report.pdf also by Dr. Talbot. Both are available from her website: www.dickamaw-books.com. (Dr. Talbot is the author and maintainer of the datatool package discussed briefly in this column.) These two books were written more than 10 years ago, and there has been a significant upgrade in Latex in that time. Nevertheless they remain valuable resources.
Next time, I will take a look at some of the packages in the E topic section of ctan.org. After that, I will look at using Latex when typesetting languages that do not use the default Latin alphabet, i.e. most languages of the world.