Outils pour utilisateurs

Outils du site


issue123:tutoriel1

In my last article, I explained Zim Wiki’s ability to be a shortcut for creating LaTeX documents, or at least creating text that can be easily imported into a LaTeX document. Importing text created in another program is not as straightforward as we may think. One issue is the way LaTeX handles characters such as ampersand, quotation marks and dollar signs. Cutting and pasting from a text editor or web page straight into a LaTeX editor can cause some strange characters to appear in your PDF file if your text includes symbols to which LaTeX takes exception. This creates a lot of grunt work that can be eliminated with applications that are configured to handle the exceptions and deal with them for you. Two programs available in your Ubuntu repositories are Pandoc and Writer2Latex. You may install them via Synaptic or the command-line. If you are composing LaTeX documents on the Raspberry Pi, please be aware that Writer2Latex will add 106 MB of files to your disk. This may or may not be a problem, depending on the size of your SD card.

Dans mon dernier article, j'ai expliqué comment le Zim Wiki pouvait servir de raccourci pour la création de documents LaTeX, ou, du moins, la création de texte qui peut être facilement importé dans un document LaTeX. L'importation du texte créé dans un autre programme n'est pas aussi simple qu'on pourrait le croire. Un des problèmes est la façon dont LaTeX gère des caractères tels que l'esperluette, les guillemets et le symbole du dollar. Faire un copier/coller d'un éditeur de texte ou d'une page Web directement dans un éditeur LaTeX peut causer l'apparition de quelques caractères bizarres dans le fichier PDF, si votre texte comprend des symboles qui, pour LaTeX, sont des exceptions inconnues. Cela crée beaucoup de travail fastidieux que vous pouvez éliminer avec des applications paramétrées pour gérer les exceptions et les traiter à votre place.

Deux programmes, Pandoc et Writer2Latex, sont disponibles dans les dépôts Ubuntu. Vous pouvez les installer via Synaptic ou la ligne de commande. Si vous composez des documents LaTeX sur un Raspberry Pi, il faut savoir que Writer2Latex ajoutera 106 Mo de fichiers sur votre disque. Selon la taille de votre carte SD cela peut être un problème, ou pas.

Pandoc I am impressed with what Pandoc will do, especially with HTML files. Pandoc processed an HTML file that was mostly a table and did it quite well. I did have to edit my .tex file, though. First I had to add “\usepackage{longtable}” to my preamble, and I had to set my page margins with “\usepackage[left=0.50cm, right=0.50cm, top=1.00cm, bottom=1.00cm]{geometry}. In this conversion of an HTML table, Pandoc placed some code into the document that my LaTeX editor did not like. We see them in the form of the nasty error messages that pop up during the compile and view PDF stage. There are two things you can do: • Search on Google for the error and you may find a solution. Often this can be as easy as adding another line or two to your preamble. • Comment out the offending line of code with a “%” at the beginning of the line.

Pandoc

Ce que Pandoc fera, surtout avec des fichiers HTML, m'a impressionné. Pandoc a traité un fichier HTML qui était pour la plus grande part une table et l'a fait très bien. Il m'a fallu toutefois éditer le fichier texte. D'abord, j'ai dû ajouter « \usepackage{longtable} » à mon préambule, puis configurer les marges de la page avec « \usepackage[left=0.50cm, right=0.50cm, top=1.00cm, bottom=1.00cm]{geometry} ».

Lors de cette conversion d'une table en HTML, Pandoc a mis du code dans le document que mon éditeur LaTeX n'appréciait pas. Les instances de cela sont visibles sous forme de messages d'erreur qui paraissent pendant la compilation et l'étape d'affichage du PDF. Il y a deux choses que vous pouvez faire : • Recherchez l'erreur sur Google et vous trouverez peut-être une solution. Souvent, cela peut être aussi facile que l'ajout d'une ou deux lignes au préambule. • Commenter la ligne de code qui fâche avec un « % » au début de la ligne.

Pandoc is a command-line application but it is user-friendly. An example of a basic command is: pandoc -s -o filename.tex filename.odt filename.tex is what the resulting LaTeX file will be; filename.odt is the original file. (use the appropriate extension for your file.) More information can be found at the Pandoc website: http://pandoc.org/ As good as Pandoc is, it has its limitations, as far as I know, concerning files from word processors. For example, Pandoc did not translate a very small simple table I made in an .odt file. This is surprising when I consider the great job Pandoc did on an HTML file that was mostly in a table format. This is where Writer2LaTeX comes in.

Pandoc est une application en ligne de commande, mais elle est conviviale. Voici une commande de base :

pandoc -s -o filename.tex filename.odt

filename.tex est le nom du fichier LaTex de sortie ; filename.odt est le fichier d'origine. (Utilisez la bonne extension pour votre fichier.)

Vous trouverez plus d'informations sur le site Web de Pandoc : http://pandoc.org/

Aussi bonne soit-elle, à ma connaissance, elle a des limitations concernant des fichiers venant de programmes de traitement de texte. Par exemple, Pandoc n'a pas traduit une très petite table simple que j'ai faite dans un fichier .odt. C'est surprenant, étant donné le travail formidable qu'elle a fait sur un fichier HTML qui était presque entièrement en format table. C'est ici que Writer2LaTeX entre en scène.

Writer2LaTeX The website http://writer2latex.sourceforge.net/ has all the information about what the program can handle, and you may want to consult it before committing to use it for a large project. But it looks like it can convert anything we can create in an .odt document. If your original has been created in Microsoft Word, you will have to open the file in LibreOffice, save the file as an .odt document and then convert. The command-line input is just as user friendly as Pandoc: w2l filename.odt filename.tex. You may have noticed that the files are in the reverse order of the command you would use for Pandoc. You type in the name of the input file first and then the output tex file. I have tried it on an .odt file with a table in it and it worked like a charm. Moreover, Writer2LaTeX can handle some fairly complex .odt documents.

Writer2LaTeX

Le site Web http://writer2latex.sourceforge.net/ contient toutes les informations sur ce que le programme peut gérer ; vous voudriez sans doute le consulter avant de décider de l'utiliser sur un grand projet. Cela dit, j'ai l'impression qu'il peut convertir tout ce que l'on peut créer dans un document .odt. Si l'original a été créé dans Microsoft Word, vous devrez ouvrir le fichier dans LibreOffice et l'enregistrer en format .odt, puis le convertir. L'entrée en ligne de commande est tout aussi conviviale que celle de Pandoc :

w2l filename.odt filename.tex

Vous pourriez avoir remarqué que l'ordre des fichiers est inversé par rapport à la commande que vous utiliseriez dans Pandoc. Vous saisissez d'abord le nom du fichier source et, ensuite, le fichier tex de sortie. Je l'ai essayé sur un fichier .odt contenant une table et il a fonctionné merveilleusement bien. Qui plus est, Writer2LaTeX sait gérer des documents .odt assez complexes.

The manual for writer2latex is a whopping eighty-four pages long. There is lots to sink your teeth into, and it’s well worth the time to take a look at it so that you have an idea of what can be done. You will also find information on these other applications: Writer2BibTeX, Writer2xhtml and Calc2xhtml. The good news is that when you want to bring data into LaTeX from other sources, you have some very good tools at your disposal to make life easier. And the help you need is just a command line entry way. Resources: Writer2LaTeX: http://writer2latex.sourceforge.net/ Pandoc: http://pandoc.org/

Avec quatre-vingt-quatre pages, le manuel de writer2latex est énorme. Il y a beaucoup de choses à absorber, mais ça vaut le coup de prendre le temps de l'examiner afin de savoir ce que vous pouvez faire avec.

Vous y trouverez aussi des informations sur ces autres applications : Writer2BibTeX, Writer2xhtml et Calc2xhtml.

La bonne nouvelle est que, quand vous voulez importer des données dans LaTeX à partir d'autres sources, il y a quelques très bons outils à votre disposition, pour vous rendre la vie plus facile. Et l'aide en ligne de commande est au bout de vos doigts.

Ressources : Writer2LaTeX: http://writer2latex.sourceforge.net/

Pandoc: http://pandoc.org/

issue123/tutoriel1.txt · Dernière modification : 2017/08/08 14:51 de andre_domenech