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).

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

  • Wow, that looks amazing, thank you very much! And thanks for the information, too. I'll try this. – Gal Grünfeld Dec 7 '16 at 1: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 7 '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 7 '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 7 '16 at 13:10
  • Lyx won't let you remove \lipsum from the body of the document??? – Bernard Dec 7 '16 at 13:53

Your Answer

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

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