Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
e4b99a39
Commit
e4b99a39
authored
25 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
can now generate <table nicer> nicer
Rev: tutorial/latex.pike:1.13
parent
8039a360
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tutorial/latex.pike
+58
-9
58 additions, 9 deletions
tutorial/latex.pike
with
58 additions
and
9 deletions
tutorial/latex.pike
+
58
−
9
View file @
e4b99a39
...
...
@@ -25,6 +25,8 @@ string packages =
\\usepackage{amsmath}
\\usepackage{longtable}
\\usepackage{graphicx}
\\usepackage{color} % colors becomes wrong in xdvi, but right in postscript
\\usepackage{colortbl}
";
...
...
@@ -322,6 +324,7 @@ string low_latex_quote(string text)
string latex_quote(string text)
{
if(!strlen(text)) return text;
if(!pre)
{
if(text[-1]=='\n') text[-1]=' ';
...
...
@@ -397,14 +400,27 @@ string mkref(string label)
string convert_table(TAG table)
{
SGML data=table->data;
int rows,columns;
int rows,columns
,nicer,framed
;
// FIXME, nicer tables not supported (yet)
// border: lines around each cell
int border=(int)table->params->border;
// framed: line around table
int framed=(int)table->params->framed;
// extra space between columns
int spaced;
if(table->params->nicer)
{
table->params->border="1";
nicer=1;
framed=1;
border=0;
spaced=1;
}
int border=(int)table->params->
border;
framed|=
border;
array(float) column_data=allocate(100,1.0);
...
...
@@ -682,18 +698,21 @@ string convert_table(TAG table)
float total_data=`+(@column_data);
string fmt=(border ? "|" : "") + ("l"+(border ? "|" : ""))*columns;
string ret="\n\n\\begin{longtable}{"+ fmt +"}\n";
string fmt=(({"l"}) * columns) * (border?"|": (spaced?"l":"") );
if(framed) fmt="|"+fmt+"|";
if(border) ret+="\\hline\n"
;
array(string) ret_rows=({})
;
in_table++;
int rownum;
// FIXME: handle <th>
foreach(table, array(Cell) row)
{
array(string) ltxrow=({});
int head;
for(int col=0;col<columns;col+=row[col]->cols)
{
...
...
@@ -701,6 +720,10 @@ string convert_table(TAG table)
int cols=row[col]->cols;
if(cols > 1) r+="\\multicolumn{"+cols+"}{l}{";
r+="\\begin{minipage}{"+actual_widths[col]+"pt}\n";
if(row[col]->tag->tag == "th")
head=1;
switch(row[col]->tag->params->align)
{
// FIXME: might need to add \\ to end of each line
...
...
@@ -726,11 +749,37 @@ string convert_table(TAG table)
if(cols > 1) r+="}";
ltxrow+=({r});
}
ret+=ltxrow*" & "+"\\\\\n";
if(border) ret+="\\hline\n";
string color="";
string colorend="";
if(nicer)
{
if(head)
{
color="\\rowcolor[rgb]{0.153,0.13,0.357}%%\n";
for(int e=0;e<sizeof(ltxrow);e++)
ltxrow[e]="\\color[rgb]{1,1,1}%\n"+ltxrow[e];
ltxrow[-1]+="\\normalcolor ";
}else{
color=sprintf("\\rowcolor[rgb]{%s}%%\n",(rownum++&1)?"1,1,1":"0.867,0.933,1");
}
}
ret_rows+=({
color+
ltxrow* (spaced?" & $\\;$ & ":" & ")+
(head ? "\\endhead\n" : "\\\\\n" )
});
}
in_table--;
string ret="\n\n\\begin{longtable}{"+ fmt +"}\n";
if(framed && !border) ret+="\\hline\\endfoot\n";
if(framed) ret+="\\hline\n";
ret+=ret_rows * ( border ? "\\hline\n" : "" );
if(framed) ret+="\\hline\n";
ret+="\\end{longtable}\n";
return ret;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment