2

I want to customize a table that I made in a certain way, and solve a problem that I have because of the table. I'll my current table details first (looks & code), and after that, I'll ask the question and describe the answer:

I used the comment from here and tweaked it to create a table that looks like this after execution of the code (PDF): This how the table looks

And this is how it's positions in the page after execution of the code (PDF): This is how the table is positioned in the executed PDF

And this is the code:

\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\centering
\begin{table}
\centering
\begin{tabular}{ C{2cm} | C{2cm} | C{2cm} | C{2cm} | C{2cm}}
  Advanced Mathematical Nonsense 2 & Homework Assignment \#$\epsilon$ & Due   Date: too/late/now & Mr. Potato Mushface & ID Number: 000000000\\
\end{tabular}
\end{table}
\end{document}

The problem that

What I want to do, is to change 3 things about the table: 1. I want it to be stuck to the top of the page. 2. I want to it to appear at the top of every page of the PDF 3. I want it to stretch its width equally to 100% of the page's width

And the problem is: After the table, I can't add add anything in LyX - nothing that I write appears in the executed PDF, even though that I can see both code in the Preamables area and in LyX's text editing area.

I'd be glad for you to refer me to reading resources. I've mostly find very long things that weren't very relevant to me, or were, but required me to learn about a lot of things and control, knowledge-wise, about how this works (I'm trying to prevent that - I'm trying only to create a header for a homework LyX class, and want to spend as less time as I can on this), and I did find a few useful answers to questions on TeX.StackExchange (like making a table have equally-wide columns), but I don't know how to make everything that I found work together, just so you know that I already searched for similar things.

Thanks A HUGE LOT to helpers in advance, and if there's anything you need to know to help, or, again, any relevant things that you can refer me to, I'd appreciate that very much, if there are short explanations there (or even better, if you explain them yourself).

1 Answers1

3

Don't use the tableenvironment since you don't want your tabular to float. Here is a possible code, using fancyhdr, tabularx and xcolor, with option table. I had to change the value of \headheight, which I did through the geometry package:

\documentclass{article}

\usepackage[table, x11names]{xcolor}
\usepackage[headheight=45pt]{geometry}%
 \usepackage{tabularx}%
\usepackage{lipsum} \usepackage{fancyhdr}
\fancyhf{}
\pagestyle{fancy}
\renewcommand{\tabularxcolumn}[1]{>{\small\bfseries\centering\color{white}\arraybackslash}m{#1}}
\renewcommand{\headrulewidth}{0pt}
%\chead{\sffamily\begin{tabularx}{\textwidth}
\cfoot{\thepage} \chead{\sffamily\begin{tabularx}{\textwidth}{>{\columncolor{DeepSkyBlue4!90}[5.8pt][4pt]}X *{3}{>{\columncolor{DeepSkyBlue4!90}[4pt][4pt]}X}>{\columncolor{DeepSkyBlue4!90}[4pt][5.8pt]}X}
Advanced Mathematical Nonsense 2 & Homework Assignment \#$\epsilon$ & Due Date: too/late/now & Mr. Potato Mushface & ID Number: 000000000
\end{tabularx}}
\cfoot{\thepage} 
\usepackage{lipsum}

\begin{document}

\lipsum

\end{document} 

enter image description here

If you want coloured vertical rules, use this code for \chead:

\chead{\sffamily\begin{tabularx}{\textwidth}
{>{\columncolor{DeepSkyBlue4!90}[5.8pt][6pt]}X!{\color{Salmon1}\vrule width1pt}*{3}{>{\columncolor{DeepSkyBlue4!90}[6pt][6pt]}X!{\color{Salmon1}\vrule width1pt}}>{\columncolor{DeepSkyBlue4!90}[6pt][6pt]}X}
 Advanced Mathematical Nonsense 2 & Homework Assignment \#$\epsilon$ & Due Date: too/late/now & Mr. Potato Mushface & ID Number: 000000000
 \end{tabularx}}%% for vertical coloured rules

enter image description here

Bernard
  • 271,350
  • Wow, that looks amazing, thank you very much! And thanks for the information, too. I'll try this. – Gal Grünfeld Dec 07 '16 at 01:33
  • There are 2 things that aren't in your solution working that I wanted to work:
    1. There aren't any vertical lines between each of the columns. How can I add them?
    2. I tried deleting the `usepackage{lipsum}' and all the other "lorem iposum" related things.

    With and without them, LyX doesn't display anything that I write outside Premables.

    This code that I have right now can be viewed here.

    – Gal Grünfeld Dec 07 '16 at 13:04
  • lipsum is just to make some fake text for the demo. Of course for a real use you remove it. For the vertical rules, I'll update in a moment. – Bernard Dec 07 '16 at 13:08
  • I know what lorem iposum is. One of the problems is that I can't display anything else that's written in LyX in the text editing area, and that only things that are written in the Preamables are compiled, from what it seems to me. – Gal Grünfeld Dec 07 '16 at 13:10
  • Lyx won't let you remove \lipsum from the body of the document??? – Bernard Dec 07 '16 at 13:53
  • I tried removing a few combination of parts of the code. Now, I tried deleting just \lipsum and LyX gave me the error after I try to compile the file into PDF: "No output rifle was generated." – Gal Grünfeld Dec 07 '16 at 14:05
  • The probleem is I don't know LyX. Try removing the auxiliary files. B.t.w. what's an utput rifle? A gun? ;o) – Bernard Dec 07 '16 at 14:19
  • Haha, "damn auto correct" :P I meant "output file". The only non-default output file that I have is a different bind file (I used a recommended one for Hebrew writing in LyX from the Hebrew University of Jerusalem). I can link you to it, if you want to look at it. – Gal Grünfeld Dec 07 '16 at 14:22
  • I can take a look, but I don't guarantee I'll be able to help. – Bernard Dec 07 '16 at 14:27
  • You can download the bind file from here. I took the file from here – Gal Grünfeld Dec 07 '16 at 15:03
  • I'm sorry, I can't help since I don't have LyX installed. I thought it was a LaTeX specific problem. But I'm sure some LyX user will be able to help. – Bernard Dec 07 '16 at 15:11
  • Yeah, it was lack of clarity from my side. Sorry about that.

    Thanks for the willing to help, though! My problem isn't solved yet, so I'm not accepting your answer as a solution to my problem.

    – Gal Grünfeld Dec 07 '16 at 15:18
  • It's the first time a LyX user tells me he can't change a LaTeX code. Maybe this is due to typing in a right-to-left language ? – Bernard Dec 07 '16 at 15:38
  • Due to the bind file, or writing in RTL? I have a shortcut that switches to a Hebrew secondary key mapping (I think that this is what it's called), and I have cursed direction set to visual. Nothing more than that. I can edit the LyX code. I just can't compile a PDF out of the LyX file. – Gal Grünfeld Dec 07 '16 at 15:55