মডিউল:Table

উইকিসংকলন থেকে
Description
This template is used to create a table of contents entry , or for simple tables.
A table of contents entry consists of three parts, from left to right:
  • (Optionally) the section number;
  • a label ;
  • The page number.
Syntax
{{Table

General settings :

| space= : margin before and after input : (default: 0.125em).
| width= : total width (default: 100% ).).
| align=: table alignment (default: center ), possible values: left, right .
| color= : color of the text and dotted lines (default is the current color not modified).
| color_font= : background color (default: #FFFFFF ; white if dotted lines are present, otherwise transparent ).

Parameters for displaying the section number:

| section= : chapter number, section (to be separated only if these numbers align right before the title).
| width=width of the cell containing the section, in pixels (default: 45 ).
| aligns=  : alignment of the section (default: right ), possible values: left, center .

Parameters for displaying the label:

| title= : label of the chapter or the section (by putting the link of the page, one can go directly to this part of text).
| indentation= : alinéa de la première ligne, positive ou négative (par défaut en em : 0).
| indentation_unit = : unité d’indentation (par défaut : em).
| text_align= : alignement du texte (par défaut : justify), valeurs possibles : left, center, right.

Paramètres concernant l'affichage du numéro de page :

| nodots (ou 1 = nodots) : si présent, supprime les pointillés (utile surtout s’il n’y a pas de numéro de page aligné à droite).
| page= : numéro de la page (en mettant le lien de la page .djvu, on pourra accéder directement au mode page). Le modèle {{pli}} permet de construire un lien à partir du numéro de page et d'un décalage, sans inscrire à chaque fois le nom du fichier.
| widthp= : largeur de la cellule contenant les pages en pixels (par défaut : 0).
}}
Exemples

টেমপ্লেট:Boîte déroulante début

{{Table|largeur=50%|align=right|couleur=red|couleur_fond=rgb(255,249,83)
| section=I.
| titre=[[Macbeth]]
| nodots
| page=71
}}
{{Table|largeur=50%|align=right|couleur=red|couleur_fond=rgb(255,249,83)
| section=II.
| titre=[[Le roi Jean/Traduction Hugo|Le roi Jean]]
| nodots
| page=175
}}
{{Table|largeur=50%|align=right|couleur=red|couleur_fond=rgb(255,249,83)
| section=III.
| titre=[[Richard III]]
| nodots
| page=281
}}
Remarque : la balise rgb(255,249,83) assigne la couleur de l’arrière-plan du modèle documentation, voir ici pour les autres formats.

টেমপ্লেট:Boîte déroulante fin

I. 
71
II. 
175
III. 
281


টেমপ্লেট:Boîte déroulante début

{{Table|section=I.|aligns=left|titre=[[De la Terre à la Lune/Chapitre 1|Le Gun-Club]]|page=[[:fr:Page:Verne - De la Terre à la lune.djvu/5|1]]|indentation=-1}}
{{Table|section=II.|aligns=left|titre=[[De la Terre à la Lune/Chapitre 2|Communication du Président Barbicane]]|page=[[:fr:Page:Verne - De la Terre à la lune.djvu/12|8]]|indentation=-1}}
{{Table|section=III.|aligns=left|titre=[[De la Terre à la Lune/Chapitre 3|Effet de la communication Barbicane]]|page=[[:fr:Page:Verne - De la Terre à la lune.djvu/19|15]]|indentation=-1}}

টেমপ্লেট:Boîte déroulante fin

I. 
 
 1
II. 
 
 8
III. 
 
 15


টেমপ্লেট:Boîte déroulante/début

{{Table|largeur=36em|largeurp=50|indentation=-1
| titre = [[Mémoires historiques et physiques sur les tremblemens de terre/Mémoire 1|I. {{sc|Mémoire}}]]. Théorie générale des tremblemens de terre
| page = [[:fr:Page:Bertrand - Mémoires historiques et physiques sur les tremblemens de terre.djvu/5|''Page'' 1.]]
}}
{{Table|largeur=36em|largeurp=50|indentation=-1
| titre = [[Mémoires historiques et physiques sur les tremblemens de terre/Mémoire 2|II. {{sc|Mémoire}}]]. Relation chronologique des tremblemens de terre de la Suisse, depuis le VIe. Siècle jusqu’à nos jours. On a joint dans cette relation les tremblemens des autres Pays, qui coïncident avec ceux de la Suisse. On y fait en particulier observer ces secousses, qui semblent parcourir tout le globe de la terre.
| page = [[:fr:Page:Bertrand - Mémoires historiques et physiques sur les tremblemens de terre.djvu/26|''Page'' 22.]]
}}

টেমপ্লেট:Boîte déroulante/fin


টেমপ্লেট:Boîte déroulante/début

{{Table|largeur=36em|largeurp=50
| titre = [[Mémoires historiques et physiques sur les tremblemens de terre/Mémoire 1|I. {{sc|Mémoire}}]]. Théorie générale des tremblemens de terre
| page = [[:fr:Page:Bertrand - Mémoires historiques et physiques sur les tremblemens de terre.djvu/5|''Page'' 1.]]
}}
{{Table|largeur=36em|largeurp=50
| titre = [[Mémoires historiques et physiques sur les tremblemens de terre/Mémoire 2|II. {{sc|Mémoire}}]]. Relation chronologique des tremblemens de terre de la Suisse, depuis le VIe. Siècle jusqu’à nos jours. On a joint dans cette relation les tremblemens des autres Pays, qui coïncident avec ceux de la Suisse. On y fait en particulier observer ces secousses, qui semblent parcourir tout le globe de la terre.
| page = [[:fr:Page:Bertrand - Mémoires historiques et physiques sur les tremblemens de terre.djvu/26|''Page'' 22.]]
}}

টেমপ্লেট:Boîte déroulante fin


টেমপ্লেট:Boîte déroulante/début

{{Table|largeur=36em|largeurs=80|largeurp=50
| nodots
| page = <small>''Page''</small>
}}
{{Table|largeur=36em|largeurs=80|largeurp=50
| section = [[Mémoires historiques et physiques sur les tremblemens de terre/Mémoire 1|Chapitre I. —]]
| titre = {{sc|Mémoire}}. Théorie générale des tremblemens de terre
| page = [[:fr:Page:Bertrand - Mémoires historiques et physiques sur les tremblemens de terre.djvu/5|1]]
}}
{{Table|largeur=36em|largeurs=80|largeurp=50
| section = [[Mémoires historiques et physiques sur les tremblemens de terre/Mémoire 1|II. —]]
| titre = {{sc|Mémoire}}. Relation chronologique des tremblemens de terre de la Suisse, depuis le VIe. Siècle jusqu’à nos jours. On a joint dans cette relation les tremblemens des autres Pays, qui coïncident avec ceux de la Suisse. On y fait en particulier observer ces secousses, qui semblent parcourir tout le globe de la terre.
| page = [[:fr:Page:Bertrand - Mémoires historiques et physiques sur les tremblemens de terre.djvu/26|22]]
}}

টেমপ্লেট:Boîte déroulante fin

Page
 22


Cas des epubs
Dans le cas de constitution d’une table des matières lisible en exportation ePub, il faudra :
  1. Constituer chaque entrée de la table par le modèle table en veillant à bien utiliser les Titrex ({{t2}}, {{t3}}, ({{t4}}).
  2. Constituer les chapitres/sections sur une page d’appel (comme ici).
  3. Exporter sur Export tool of Wikisource books (expérimental mais fonctionnel).
Remarque : le fichier ePub ou la page web constituée aura deux liens hypertexts : le libellé de l’entrée permettra d’accéder au texte, quant au folio (numéro de page), il donne l’accès de la page source en mode page.


Voir aussi
  • {{Page link}} (ou {{Pli}}) : pour faciliter l'établissement de liens vers les pages
  • {{t2}} : titre de 2e niveau mais de 1er niveau d’un livre
  • {{t3}} : titre de 3e niveau mais de 2e niveau d’un livre
  • {{t4}} : titre de 4e niveau mais de 3e niveau d’un livre
  • {{Ebook-Tn}} : crée une ligne de sommaire pour un ebook


Catégorie:Modèles de tableau


function table( frame )

    local args = frame.args

    local not_nodots = args[1] == nil or mw.text.trim( args[1] ) ~= 'nodots'

     -- General container (relative and non- transparent background) Table positioning
    local text = string.format( '<div class="tableItem" style="position:relative;margin:%s auto;',
                                 out_arg( args.espace, ".125em" ) )
    if args.align == 'left' or args.align == 'right' then
        text = text .. string.format('margin-%s:0;', args.align)
    end

    if args.largeur and args.largeur ~= '' then
        text = text .. string.format('width:%s;', args.largeur)
    end

    if args.color_background and args.color_background ~= '' then
        text = text .. string.format('background:%s;', args.color_background)
    elseif not_nodots then
        text = text .. 'background:#FFF;'
    end

    if args.color and args.color ~= '' then
        text = text .. string.format('color:%s;', args.color)
    elseif not_nodots then
        text = text .. 'color:#000;'
    end

    text = text .. 'line-height:normal">' -- Fin de l'ouverture du div externe

    -- TDM : Container with section + title + page (only necessary if page number)
    if args.page and args.page ~= '' then
        text = text .. string.format( '<div style="margin-right:%spx">', out_arg( args.largeurp, "0" ) )
        -- LEFT + CENTER : Floating Container left with + section title (only necessary if page number)
        text = text .. '<div style="float:left;width:100%">'
    end

    -- LEFT : left section number floating container ( if not transparent dotted )
    if args.section and args.section ~= '' then
        text = text .. string.format( '<div style="float:left;z-index:2;min-width:%spx;text-indent:0;text-align:%s;white-space:nowrap">',
                                      out_arg( args.largeurs, 45), out_arg( args.aligns, 'right') )

        if not_nodots then
            text = text .. string.format('<span style="background:%s">', out_arg( args.color_background, '#FFF' ) )
        end
        text = text .. args.section .. '&nbsp;'
        if not_nodots then
            text = text .. '</span>'
        end
        text = text .. '</div>'

        -- CENTRE : Container title and dashed 
        text = text .. string.format( '<div style="position:relative;margin-left:%spx">', out_arg(args.largeurs, 45) )
    end

    -- Optional internal container to manage the negative margin indentation
    if tonumber( out_arg(args.indentation, 0 ) ) < 0 then
        text = text .. string.format( '<div style="margin-left:%s%s;text-indent:%s%s">',
                                      -args.indentation, out_arg(args.indentation_unit, "em"), args.indentation, out_arg(args.indentation_unit, "em" ) )
    end

    -- The title itself ( justifiable indentable ) , the top of the container CENTRE ( if not transparent dotted )
    text = text .. '<div style="position:relative;z-index:2;'
    if args.text_align and args.text_align ~= 'justify' then
        text = text .. string.format( 'text-align:%s;', args.text_align )
    end
    if tonumber( out_arg(args.indentation, 0 ) ) > 0 then
        text = text .. string.format( 'text-indent:%s%s', args.indentation, out_arg(args.indentation_unit, "em" ) )
    end
    text = text .. '">'
    if not_nodots then
         text = text .. string.format('<span style="background:%s">', out_arg( args.color_background, '#FFF' ) )
    end
    text = text .. out_arg(args.title, '' )
    if not_nodots then
        text = text .. '&nbsp;</span>'
    end
    text = text .. '</div>'

    -- End of optional internal container to manage the negative margin indentation
    if tonumber( out_arg(args.indentation, 0 ) ) < 0 then
        text = text  .. '</div>'
    end

    -- Prospective dotted (bunk below, requires an absolute positioning in the container CENTRE )
    if not_nodots then
        text = text .. '<div class="ws-noexport" style="position:relative;'
        text = text .. string.format( 'margin-left:%d%s">', math.abs( tonumber( out_arg( args.indentation, "0" ) ) ) + 1, out_arg( args.indentation_unit, "em" ) )
        text = text .. '<div style="position:absolute;z-index:1;bottom:.3em;width:100%;border-bottom:0.135em dotted '
        text = text .. out_arg( args.color, '#000' ) .. '"></div>'
        text = text .. '</div>'
    end

    -- CENTRE : End of title container and dotted
    if args.section and args.section ~= '' then
        text = text .. '</div>'
        -- Extends vertically floating the left ( section number )
        text = text .. '<div class="ws-noexport" style="clear:both"></div>'
    end

    if args.page and args.page ~= '' then
        -- LEFT + CENTRE: End of container with + section title (only necessary if page number)
        text = text .. '</div>'
        -- RIGHT: floating container to the right of the page number (only necessary if page number)
        text = text .. '<div class="ws-noexport" style="float:right">'
        -- The issue , indivisible , is positioned vertically downward in the floating (not clear if dashes)
        text = text .. '<div style="position:absolute;z-index:2;bottom:0;right:0;text-indent:0;text-align:right;white-space:nowrap">'
        if not_nodots then
            text = text .. string.format('<span style="background:%s">', out_arg( args.color_background, '#FFF' ) )
            -- only to avoid sticking to the dotted line
            text = text .. '&nbsp;'
        end
        text = text .. args.page
        if not_nodots then
            text = text .. '</span>'
        end
        text = text .. '</div>'
        -- RIGHT: End of floating container page number (only necessary if page number)
        text = text .. '</div>'

        -- Extends vertically floating the right (to move down the page number )
        text = text .. '<div class="ws-noexport" style="clear:both"></div>'

        -- TDM :End section of the container with + title + page (only necessary if page number)
        text = text .. '</div>'
    end

    -- EXTERNAL: End of container
    text = text .. '</div>'

    return text
end

function out_arg( arg, default )
    if arg and arg ~= '' then
        return arg
    end
    return default
end

local p = {}

-- Aid debugging , returns the generated code as a string encoded
-- and as html.
function p.table_as_string( frame )
    return mw.text.encode( table( frame ) ) .. '<div style="clear:both"></div>' .. table( frame )
end
 
function p.table( frame )
    return table( frame:getParent() )
end
 
return p