This is the entire module that contains all code to output with a Print[Grid[data, rules]] statement. I have all cells arranged in stacked rows in a convenient data = {{...,rules},...}variable. Most style rules are placed inside the grid however some style rules (//TraditionalForm) reside in data elements.

Questions: (1) Why aren't cell contents aligning along the vertical (especially left column INPUT and OUTPUT)? (2) How to remove all styles inside data contents and move them to Grid[data{{...},..}}, all rules go here]. (3) How to repair spacing of cells. Goal for this is a spacing of 1em around all contents of all cells.

navy := RGBColor[0, 0, 0.5, 
  1] (* navy is a slightly darker DarkBlue *)
lime := RGBColor[.2, 1, .2, 1](* slightly darker Lime *)
cauchy[ic_ : (u[0, x] == Exp[-x] Sin[x]^2), bc_ : (u[t, 0] == 0), 
  domt_ : {0, 3}, domx_ : {0, 3}, range_ : Automatic] := 
 Module[{eqn, sol, ver, data, reg},
  eqn = (D[u[t, x], t] + D[u[t, x], x] == 0);
  sol = First[DSolve[{eqn, ic, bc}, u, {t, x}]];
  ver = If[eqn /. sol // FullSimplify, Style["True", lime], 
    Style["False", Background -> Red],
    Style["Indeterminate", Black, Background -> Yellow]];
  reg = Rectangle[{domt[[1]], domx[[1]]}, {domt[[2]], domx[[2]]}];
  data = {
DIFFERENTIAL EQUATION", Bold], SpanFromLeft, SpanFromLeft},
    {"", Style["PARAMETERS", Bold], Style["RESULTS", Bold]},
    {Rotate[Style["INPUTS", Bold], 90 Degree], 
     "initial conditions (ic)", ic // TraditionalForm},
    {SpanFromAbove, "boundary conditions (bc)", bc // TraditionalForm},
    {SpanFromAbove, "domain in t (domt)", domt // TraditionalForm},
    {SpanFromAbove, "domain in x (domx)", domx // TraditionalForm},
    {SpanFromAbove, "domains destructure to form surface region(reg)",
      reg // TraditionalForm},
    {SpanFromAbove, "range in u[t,x] (range)", 
     range // TraditionalForm},
    {Rotate[Style["OUTPUTS", Bold], 90 Degree], 
     "cauchy equation(eqn//TraditionalForm )", eqn // TraditionalForm},
    {SpanFromAbove, "solution (sol[[1]])", sol // TraditionalForm},
    {SpanFromAbove, "solution (sol[[1]]//FullSimplify)", 
     sol // FullSimplify // TraditionalForm},
    {SpanFromAbove, "solution verified as", ver},
    {SpanFromAbove, "comment on solution from default values", 
     "plot assumes a traveling wave" // TraditionalForm}};
  Print[Grid[data, Frame -> All, FrameStyle -> Thickness[1], 
    Spacings -> 2, Alignment -> {{Center, Center}}, 
    ItemSize -> Automatic, 
    BaseStyle -> {White, Bold, Background -> navy, TraditionalForm}]];
   Print[Plot3D[Evaluate[u[t, x] /. sol], {t, x} \[Element] reg, 
    PlotRange -> range, AxesLabel -> Automatic]]
  • $\begingroup$ lime and navy are not defined. $\endgroup$ – Nasser Apr 23 at 2:59
  • 1
    $\begingroup$ use Alignment -> {Center, Center} instead of Alignment -> {{Center, Center}}? $\endgroup$ – kglr Apr 23 at 3:06
  • $\begingroup$ @Nasser so sorry about that . I know youre trying to help me. Its fixed now. $\endgroup$ – Jules Manson Apr 23 at 3:07
  • $\begingroup$ @Nasser thank you it worked. what about spacing all cells and moving //TranditionalForm to the Grid[data, Spacing rule, TradionalForm rule]? $\endgroup$ – Jules Manson Apr 23 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.