0
$\begingroup$

I am creating an engineering analysis report format and I want to include a table of information about details of the project in the header.

I understand that I have to edit the format in Format -> Edit Stylesheet. But, what code I have to write to get a table like this:

header

I am a new in Mathematica.

Thanks in advance.

$\endgroup$
6
  • $\begingroup$ Are you wanting to create this entire report from Mathematica, or just the header part? Both are obviously do-able, I'm just trying to scope the question. $\endgroup$
    – lericr
    Commented Dec 7, 2022 at 16:13
  • $\begingroup$ And I wouldn't think it's necessary to edit the stylesheet. Since you're thinking along those lines, maybe there's something else to this you haven't explained yet. $\endgroup$
    – lericr
    Commented Dec 7, 2022 at 16:14
  • $\begingroup$ @lericr Thank you. I want to create only the header part. $\endgroup$
    – Isai
    Commented Dec 7, 2022 at 16:16
  • $\begingroup$ What will be your final output? I do report generation where my output is a notebook which is then converted to PDF. In the notebook you can have page breaks before specific cells which can be considered as a header. $\endgroup$ Commented Dec 7, 2022 at 16:18
  • $\begingroup$ @GustavoDelfino I need a report with shown table in header in all pdf pages. $\endgroup$
    – Isai
    Commented Dec 7, 2022 at 16:24

1 Answer 1

3
$\begingroup$

This is just a partial, exploratory answer to get feedback. This is the start of an approach that just generates the header, which could then be copy-pasted to some other context where the report lives.

FieldLabel[label_] := Style[label, Bold, 12];
FieldValue[value_] := Style[value, 14, FontFamily -> "Arial"];
Field[label_, value_, width_] := 
  Grid[
    {{FieldLabel[label]}, {FieldValue[value]}}, 
    Alignment -> {Left, Center, {2, 1} -> Center}, ItemSize -> width];
Grid[
  {{TBD, Field["Job", "1529085", 20], TBD},
   {SpanFromAbove, Field["Project", "West Bridgeport", 20], TBD},
   {SpanFromAbove, Field["Client", "Com-Ex Consultants, LLC", 20], TBD}},
  Dividers -> All]

enter image description here

Considerations:

  • This demonstrates a way to generate the output programmatically with consistent/pre-defined styling. You can tweak the styling however you like. This let's you reuse this header "template".
  • If your report is actually in Mathematica, then consider just creating the header as a cell.
  • Otherwise, what is the context for your report?
  • Or, asking another way, what format will this eventually need to be in?
  • If this is heading in the right direction, I'll update to flesh out more of the content.

Update

I'm inferring from the comment from OP that there is a Mathematica notebook that constitutes the report and that what is wanted is for a customer header to be shown when the notebook is printed.

Here is one way you can do that (there will probably be some nitpicky issues to figure out as you go along):

  • Execute the code I posted above
  • Click on the output cell (just so that's where focus is)
  • Do Shift-Command-E (I'm on a Mac, I'm not sure if the command is the same on other platforms, but it's the "Show Expression" command in the Cell menu). This will show you the raw cell expression.
  • Select the entire cell expression and copy it to the clipboard
  • Open the option inspector (Shift-Command-O on mac)
  • Set the scope to be your notebook that needs the header
  • Find the PageHeaders option (you can search for it)
  • Click on the value, select everything that's there, and delete it.
  • Type this literally (this is just for convenience to make things easier to see): {{None,None,None},{None,None,None}}
  • Now, replace the second "None" in each sublist and copy-replace it with the cell expression you have on the clipboard.

Now you can test by doing a print preview. I've never done a header this complicated, so there will probably be a lot of tweaking necessary. You'll also have to work in a CounterBox for the page number.

$\endgroup$
4
  • $\begingroup$ I have the code of the footer: Cell[StyleData["Header"], CellMargins->{{0, 0}, {4, 1}}, StyleMenuListing->None, FontFamily->"Times", FontSize->9, FontSlant->"Italic" ] $\endgroup$
    – Isai
    Commented Dec 7, 2022 at 16:58
  • $\begingroup$ Where do have to paste it? I have tried inside Cell command, but it doesn't work. $\endgroup$
    – Isai
    Commented Dec 7, 2022 at 17:13
  • $\begingroup$ I found PageHeaders, but I can't change the Value, I can edit it and change the Value for very little seconds, but it backs on the original values. $\endgroup$
    – Isai
    Commented Dec 7, 2022 at 20:28
  • $\begingroup$ When I did this, the code pasted was so long that the OK button was hidden. But I just tapped Enter and it was accepted. Is that what you're seeing? $\endgroup$
    – lericr
    Commented Dec 7, 2022 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.