issue182:latex
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue182:latex [2022/06/27 09:24] – créée auntiee | issue182:latex [2022/06/30 16:00] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Tables were introduced in Part 5. To review, here (top right) is a simplified version of the code needed to produce the table on p. 23 of FCM#171. | + | **Tables were introduced in Part 5. To review, here (top right) is a simplified version of the code needed to produce the table on p. 23 of FCM#171. |
- | This will produce a table without the title and without the column for minimum temperatures. There are also no Fahrenheit temperatures and no degree symbols. There is one column for each of the four months and one row for each municipality. To get the fancier features we have at least two choices. We could code the fancy features in Latex or we could build the table in a spreadsheet and export it to Latex. Since the point of these articles is to help you learn Latex we will choose the first alternative. | + | This will produce a table without the title and without the column for minimum temperatures. There are also no Fahrenheit temperatures and no degree symbols. There is one column for each of the four months and one row for each municipality. To get the fancier features we have at least two choices. We could code the fancy features in LaTeX or we could build the table in a spreadsheet and export it to LaTeX. Since the point of these articles is to help you learn LaTeX we will choose the first alternative. |
- | Converting tables to Latex: | + | Les tableaux ont été présentés dans la partie 5. Pour réviser, voici (en haut à droite) une version simplifiée du code nécessaire pour produire le tableau de la page 23 du FCM n° 171. |
- | • For those who like using spreadsheets there is an Add-In for Excel that will export a selected block of cells into a CSV file that is compatible with Latex. | + | |
+ | Cela produira un tableau sans le titre et sans la colonne des températures minimales. Il n'y a pas non plus de températures Fahrenheit ni de symboles de degrés. Il y a une colonne pour chacun des quatre mois et une ligne pour chaque municipalité. Pour obtenir des fonctions plus sophistiquées, | ||
+ | |||
+ | |||
+ | **Converting tables to LaTeX: | ||
+ | • For those who like using spreadsheets there is an Add-In for Excel that will export a selected block of cells into a CSV file that is compatible with LaTeX. | ||
• There is an extension for LibreOffice Calc called calc2latex but it has not been updated since 2008. Apparently it worked with LibreOffice 2. I tried it in LibreOffice 7. First it refused to run because of a coding error and then it crashed Calc. | • There is an extension for LibreOffice Calc called calc2latex but it has not been updated since 2008. Apparently it worked with LibreOffice 2. I tried it in LibreOffice 7. First it refused to run because of a coding error and then it crashed Calc. | ||
- | • You could build the table in Calc and then Save As a csv file. Then import the csv file into Latex. | + | • You could build the table in Calc and then Save As a csv file. Then import the csv file into LaTeX. |
- | • You could build the table in Calc and export into a graphic file format, jpeg/jpg or pdf are acceptable in Latex. Then import the graphic into your Latex document. | + | • You could build the table in Calc and export into a graphic file format, jpeg/jpg or pdf are acceptable in LaTeX. Then import the graphic into your LaTeX document. |
- | • You can build this table in LibreOffice Write since it is just text and values. (Tables that require calculations cannot be built in Write.) The WritertoLatex extension works well in Write although it will generate a tex file that may contain more complex | + | • You can build this table in LibreOffice Write since it is just text and values. (Tables that require calculations cannot be built in Write.) The WritertoLatex extension works well in Write although it will generate a tex file that may contain more complex |
- | In this example (above) I have replaced the code from Part 5 with the same table built in Calc and saved as a csv file. | + | In this example (above) I have replaced the code from Part 5 with the same table built in Calc and saved as a csv file. ** |
+ | |||
+ | Convertir des tableaux en LaTeX : | ||
+ | ••Pour ceux qui aiment utiliser des feuilles de calcul, il existe un module complémentaire pour Excel qui exporte un bloc de cellules sélectionné dans un fichier CSV compatible avec LaTeX. | ||
+ | ••Il existe une extension pour LibreOffice Calc appelée calc2latex, mais elle n'a pas été mise à jour depuis 2008. Apparemment, | ||
+ | ••Vous pouvez créer le tableau dans Calc, puis l' | ||
+ | ••Vous pouvez construire le tableau dans Calc et l' | ||
+ | ••Vous pouvez construire ce tableau dans LibreOffice Write puisqu' | ||
+ | |||
+ | Dans cet exemple (ci-dessus), | ||
- | I replaced the commas in the generated CSV file with space& | + | **I replaced the commas in the generated CSV file with space& |
This is an adequate table, roughly 50% of the desired result. The goal is a table like this (above). (If we wanted to get very fancy we could add the Fahrenheit temperatures as a separate line in each cell.) | This is an adequate table, roughly 50% of the desired result. The goal is a table like this (above). (If we wanted to get very fancy we could add the Fahrenheit temperatures as a separate line in each cell.) | ||
Ligne 19: | Ligne 34: | ||
• Merge the pairs of columns for each month. | • Merge the pairs of columns for each month. | ||
- | To set column widths, this code is altered: \begin{tabular}{||l|c|c|c|c|c|c|c|c|} | + | To set column widths, this code is altered: \begin{tabular}{||l|c|c|c|c|c|c|c|c|}** |
- | Keep the alignment instructions, | + | J'ai remplacé les virgules dans le fichier CSV généré par des espaces& |
+ | |||
+ | Il s'agit d'un tableau adéquat, qui correspond à environ 50 % du résultat souhaité. L' | ||
+ | |||
+ | Deux choses à faire ensuite : | ||
+ | ••Définir la largeur de toutes les colonnes. | ||
+ | ••Fusionner les paires de colonnes pour chaque mois. | ||
+ | |||
+ | Pour définir la largeur des colonnes, on modifie ce code : \begin{tabular}{|l|c|c|c|c|c|c|c|c|} | ||
+ | |||
+ | |||
+ | **Keep the alignment instructions, | ||
\begin{tabular}{|lp{2.4cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|} | \begin{tabular}{|lp{2.4cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|} | ||
Ligne 36: | Ligne 62: | ||
• The first argument {2} indicates how many columns are to be merged. | • The first argument {2} indicates how many columns are to be merged. | ||
• The second one {c} indicates the alignment of the text (l, c, r are possible). | • The second one {c} indicates the alignment of the text (l, c, r are possible). | ||
- | • The third {January} is the contents of this multicolumn cell. | + | • The third {January} is the contents of this multicolumn cell.** |
- | Now you should understand everything in the following line of code. The other three columns, April, July and October, follow the same pattern as January. | + | Gardez les instructions d' |
+ | |||
+ | \begin{tabular}{|lp{2.4cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|cp{1.5cm}|} | ||
+ | |||
+ | Si vous n' | ||
+ | |||
+ | Voici la partie délicate : fusionner les quatre paires de colonnes Max-Min et garder les huit colonnes de températures aux bons endroits. Voici le début de la nouvelle ligne de code avec une explication. | ||
+ | |||
+ | Municipalité& | ||
+ | |||
+ | Municipalité est le texte de la cellule actuelle de la rangée 1 et de la colonne 1. ( R1C1). L' | ||
+ | |||
+ | \multicolumn est suivi de trois arguments. | ||
+ | ••Le premier argument {2} indique combien de colonnes doivent être fusionnées. | ||
+ | ••Le deuxième {c} indique l' | ||
+ | ••Le troisième {Janvier} est le contenu de cette cellule multi-colonne. | ||
+ | |||
+ | |||
+ | **Now you should understand everything in the following line of code. The other three columns, April, July and October, follow the same pattern as January. | ||
Municipality& | Municipality& | ||
Ligne 46: | Ligne 90: | ||
Make sure the total number of merged and not-merged columns in the row with the multicolumn command matches the number of columns in the \begin{tabular} command. In this row we have 1+2+2+2+2 = 9 and the \begin{tabular} command has 1 – l and 8 – c which also equals 9. | Make sure the total number of merged and not-merged columns in the row with the multicolumn command matches the number of columns in the \begin{tabular} command. In this row we have 1+2+2+2+2 = 9 and the \begin{tabular} command has 1 – l and 8 – c which also equals 9. | ||
- | We need to add a title to our table and then we will be done. That can be done using the \caption command. That will automatically add the word “Table” and a sequence number, something like “Table 1”. Since this is a one page – one table document, we do not need Table numbering. It can also be done by adding a multicolumn row before the line starting “Municipality” | + | We need to add a title to our table and then we will be done. That can be done using the \caption command. That will automatically add the word “Table” and a sequence number, something like “Table 1”. Since this is a one page – one table document, we do not need Table numbering. It can also be done by adding a multicolumn row before the line starting “Municipality”** |
- | \multicolumn{9}{c}{Average Temperatures in Four BC Locations} should work. | + | Vous devriez maintenant comprendre tout ce que contient la ligne de code suivante. Les trois autres colonnes, avril, juillet et octobre, suivent le même schéma que janvier. |
+ | |||
+ | Municipality& | ||
+ | |||
+ | (N' | ||
+ | |||
+ | Assurez-vous que le nombre total de colonnes fusionnées et non fusionnées dans la ligne avec la commande multicolumn correspond au nombre de colonnes dans la commande \begin{tabular}. Dans cette ligne, nous avons 1+2+2+2+2 = 9 et la commande \begin{tabular} a 1 - l et 8 - c, ce qui, de même, est égal à 9. | ||
+ | |||
+ | Nous devons ajouter un titre à notre tableau et nous aurons terminé. Cela peut être fait en utilisant la commande \caption. Celle-ci ajoutera automatiquement le mot « Table » et un numéro de séquence, comme « Table 1 ». Puisqu' | ||
+ | |||
+ | |||
+ | **\multicolumn{9}{c}{Average Temperatures in Four BC Locations} should work. | ||
The test is always: will the code compile and generate the desired layout in the PDF file. | The test is always: will the code compile and generate the desired layout in the PDF file. | ||
Ligne 58: | Ligne 113: | ||
There are at least two other ways to merge cells in a Tex table. | There are at least two other ways to merge cells in a Tex table. | ||
- | Next issue: packages in Latex / Tex | + | Next issue: packages in LaTeX / Tex** |
+ | |||
+ | \multicolumn{9}{c}{Températures moyennes dans quatre endroits de la Colombie-Britannique} devrait fonctionner. | ||
+ | |||
+ | Le test est toujours le suivant : le code sera-t-il compilé et générera-t-il la mise en page souhaitée dans le fichier PDF ? | ||
+ | |||
+ | Veuillez noter : | ||
+ | |||
+ | La commande \multicolumn s' | ||
+ | |||
+ | Il existe au moins deux autres façons de fusionner les cellules d'un tableau Tex. | ||
+ | |||
+ | Dans le prochain numéro : les paquets dans LaTeX / Tex | ||
issue182/latex.1656314672.txt.gz · Dernière modification : 2022/06/27 09:24 de auntiee