5. Tables

5.1. Inserting a table

Tables are straight-forward. Position the insertion point. Either click on the Insert Table button, or use the Insert drop-down menu:

Menu bar:    Insert -> Tabular material...

Insert table dialogue:    Rows -> (number) -> Columns -> (number) -> OK
   

The 'Insert Table' dialogue shows the graphical representation of a table (initially 5x5). Select the table's size in rows and columns. You can do this by typing in the numbers you want, clicking on '+' or '-', or by moving the bottom right-hand corner of the table widget with the mouse.

NoteNote: Header row.
 

lyx assumes that the first row contains column headings. lyx shows the header row separated from the rest of the table, but SGML export ignores this.

Here is a table with 3 rows and 2 columns:

Here is the SGML:

1 <para>
2   <informaltable>
3     <tgroup cols="2" colsep="1" rowsep="1"
4     <colspec colname="col0" align="center">
5     <colspec colname="col1" align="center">
6 
7       <tbody>
8 
9         <row>
10           <entry align="center" valign="top">
11             <para>Column heading   1</para>
12           </entry>
13           <entry align="center" valign="top">
14             <para>Column Heading 2</para>
15           </entry>
16         </row>
17 
18         <row>
19           <entry align="center" valign="top">
20             <para>2nd row, 1st column</para>
21           </entry>
22           <entry align="center" valign="top">
23             <para>2nd row, 2nd column</para>
24           </entry>
25         </row>
26 
27         <row>
28           <entry align="center" valign="top">
29             <para>3rd row, 1st column</para>
30           </entry>
31           <entry align="center" valign="top">
32             <para>3rd row, 2nd column</para>
33           </entry>
34         </row>
35 
36       </tbody>
37 
38     </tgroup>
39   </informaltable>
40 </para>   
41    

5.2. Links

5.2.1. External link (URL)

NoteNote: Names of external links.
 

It is a good idea to make the name of an external link identical to the URL. That way, printed copies of the final HTML page still contain the complete URL.

This link may enable you to jump to your localhost's index page: http://localhost.

The SGML code looks like this:

1    <para>
2 This link may enable you to jump to your 
3 localhost's index page:<ulink url="http://localhost">http://localhost</ulink>.
4    </para>
5     

This link will take you to the newbieDoc home page: http://newbiedoc.sourceforge.net/.

1    <para>
2 This link will take you to the newbieDoc home page: 
3 <ulink url="http://newbiedoc.sourceforge.net/">
4 http://newbiedoc.sourceforge.net/</ulink>.
5    </para>
6     

5.2.3. Internal link (cross reference or xref)

DocBook no longer supports xref to ANCHOR. However, it does support a link using the “ID” attribute.

The value of attribute "ID" and "LINKEND" attributes must be a single token. This means that you can use alphanumeric characters (letters and numbers) and the hyphen (-). Here are a couple of examples. First the SGML generated by lyx for including IDs in this 'Appendix' and its first 'Section':

1 <appendix id="Appendix-Examples-of-LyX-styles">
2   <title>
3     Examples of LyX styles used in newbieDoc
4   </title>
5 
6   <sect1 id="Golf-links">
7     <title>
8       Links
9    </title>
10     

Now the LINKENDs:

The big, fat dog ran around the Section 5.2 all by itself.

1    <para>
2      The big, fat dog ran around the <xref linkend="Golf-links">
3      all by itself.
4    </para>
5     

The lazy fox went to Appendix B instead.

1    <para>
2      The lazy fox went to 
3      <xref linkend="app-analysis-of-lyx-styles"> instead.
4    </para>
5     

5.3. Specify a language

Suppose that you are writing in Spanish. You specify the language of your article in the document layout.

Menu bar:    Layout -> Document...

Document settings dialogue:   
Language 

Language Settings and Quote Style dialogue:   
Language -> Spanish -> OK
   

Now generate the SGML and HTML files to see the result

Menu bar:    File -> Export DocBook
   

Look at hello-world.sgml with your text editor. You should see that the article tag now includes 'lang="es"'.

View hello-world.en.html with a web browser. You should see that 'Table of Contents' has been replaced by 'Tabla de contenidos'. Of course, if you are really writing in Spanish you should change the name of the lyx file to hello-world.es.lyx.