ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 25 Oct 2011 02:31:07 +0200side by side html tableshttps://ask.sagemath.org/question/8316/side-by-side-html-tables/Is there a way to display two html tables (of different sizes) side by side?
Here is a simple, silly example. Can I display the arrays below in side by side tables?
a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,15)]
html.table(a)
html.table(b)
Sun, 11 Sep 2011 22:51:30 +0200https://ask.sagemath.org/question/8316/side-by-side-html-tables/Answer by calc314 for <p>Is there a way to display two html tables (of different sizes) side by side?</p>
<p>Here is a simple, silly example. Can I display the arrays below in side by side tables?</p>
<p>a=[[i,i^2] for i in range(0,10)]</p>
<p>b=[[i,i^3] for i in range(0,15)]</p>
<p>html.table(a)</p>
<p>html.table(b)</p>
https://ask.sagemath.org/question/8316/side-by-side-html-tables/?answer=12721#post-id-12721Thanks for all the help. This is working great!Wed, 05 Oct 2011 10:56:17 +0200https://ask.sagemath.org/question/8316/side-by-side-html-tables/?answer=12721#post-id-12721Answer by benjaminfjones for <p>Is there a way to display two html tables (of different sizes) side by side?</p>
<p>Here is a simple, silly example. Can I display the arrays below in side by side tables?</p>
<p>a=[[i,i^2] for i in range(0,10)]</p>
<p>b=[[i,i^3] for i in range(0,15)]</p>
<p>html.table(a)</p>
<p>html.table(b)</p>
https://ask.sagemath.org/question/8316/side-by-side-html-tables/?answer=12638#post-id-12638You can insert html commands to wrap the two tables into a larger table. Something like:
a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,15)]
html('<table><tr><td>')
html.table(a)
html('</td><td>')
html.table(b)
html('</td></tr></table>')
You can change the table (and row and column) style to your liking by modifying the `html` commands that wrap the `html.table` calls.Mon, 12 Sep 2011 00:05:44 +0200https://ask.sagemath.org/question/8316/side-by-side-html-tables/?answer=12638#post-id-12638Comment by kcrisman for <p>You can insert html commands to wrap the two tables into a larger table. Something like:</p>
<pre><code>a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,15)]
html('<table><tr><td>')
html.table(a)
html('</td><td>')
html.table(b)
html('</td></tr></table>')
</code></pre>
<p>You can change the table (and row and column) style to your liking by modifying the <code>html</code> commands that wrap the <code>html.table</code> calls.</p>
https://ask.sagemath.org/question/8316/side-by-side-html-tables/?comment=21262#post-id-21262This is also a good answer.Mon, 12 Sep 2011 12:05:27 +0200https://ask.sagemath.org/question/8316/side-by-side-html-tables/?comment=21262#post-id-21262Answer by kcrisman for <p>Is there a way to display two html tables (of different sizes) side by side?</p>
<p>Here is a simple, silly example. Can I display the arrays below in side by side tables?</p>
<p>a=[[i,i^2] for i in range(0,10)]</p>
<p>b=[[i,i^3] for i in range(0,15)]</p>
<p>html.table(a)</p>
<p>html.table(b)</p>
https://ask.sagemath.org/question/8316/side-by-side-html-tables/?answer=12641#post-id-12641If your tables are the same length, you can try to make just one table - I do this sometimes.
a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,10)]
c=[flatten(z) for z in zip(a,b)]
html.table(c,header=['x','f(x)','y','g(y)'])
As a corollary for your case (not the same length), it's possible to insert `None` and then replace that with `''`. Here's one I've actually used. It's a bit annoying, but doable. In this case I really didn't know how big they would be ahead of time, because `n` was potentially much bigger than 7.
n=7
L = map(None,[p for p in prime_range(n+1) if p%4==1],[p for p in prime_range(n+1) if p%4==3])
L = [['',l[1]] if l[0] is None else l for l in L]
T = [['$p\equiv 1\\text{ mod }(4)$','$p\equiv 3\\text{ mod }(4)$']]
html.table(T+L,header=True) Mon, 12 Sep 2011 12:05:18 +0200https://ask.sagemath.org/question/8316/side-by-side-html-tables/?answer=12641#post-id-12641Answer by Eugene for <p>Is there a way to display two html tables (of different sizes) side by side?</p>
<p>Here is a simple, silly example. Can I display the arrays below in side by side tables?</p>
<p>a=[[i,i^2] for i in range(0,10)]</p>
<p>b=[[i,i^3] for i in range(0,15)]</p>
<p>html.table(a)</p>
<p>html.table(b)</p>
https://ask.sagemath.org/question/8316/side-by-side-html-tables/?answer=12651#post-id-12651You can also play with div tags:
a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,15)]
html('<div style="float:left; width:256px;">')
html.table(a)
html('</div><div style="float:right; width:256px">')
html.table(b)
html('</div>')Thu, 15 Sep 2011 15:14:23 +0200https://ask.sagemath.org/question/8316/side-by-side-html-tables/?answer=12651#post-id-12651Comment by process91 for <p>You can also play with div tags:</p>
<pre><code>a=[[i,i^2] for i in range(0,10)]
b=[[i,i^3] for i in range(0,15)]
html('<div style="float:left; width:256px;">')
html.table(a)
html('</div><div style="float:right; width:256px">')
html.table(b)
html('</div>')
</code></pre>
https://ask.sagemath.org/question/8316/side-by-side-html-tables/?comment=21041#post-id-21041From a web design perspective, this is the proper way to do it.Tue, 25 Oct 2011 02:31:07 +0200https://ask.sagemath.org/question/8316/side-by-side-html-tables/?comment=21041#post-id-21041