How to add a few blank lines without using \vspace? Trying to use \\ always gets me in trouble...

Now I'm trying to format a simple lua table in LaTeX for display. I am using a combination of \\ (which requires me to use code like \noexpand\\noexpand\\) and \vspace.

The table is formated nicely EXCEPT I have to use an actual character


works fine but if I change it to



tex.print(" ")

things quickly become bad.

I've also tried


but it only works if there is some initial piece of text

My Code

for i = 0, ofs + 1*idx - 1 do
  • 3
    The correct method for inserting vertical space is \vspace when in normal text; in a tabular environment it is \\[<dimen>]. Please edit your message, removing foul language. – egreg Mar 18 '12 at 14:18
  • If you start a new line with \hspace it doesn't work. You have to use the stared form of the command: \hspace*{...}. – Holle Mar 18 '12 at 14:30
  • ok, that would then be the cause. – Uiy Mar 18 '12 at 14:32
  • 3
    Please use a decent language in your posts. I edited your question. – Stefan Kottwitz Mar 18 '12 at 14:48
  • 2
    I repeat my question: Do you need the word crap here? We don't own this place but we have reached to an equilibrium where now there is a certain reputation about the level of noise here. I think we achieved it by not trying to offend anyone. Your words are like a bird chirp to me if I consider my own daily foul language and I repeat that I am not offended. But we don't need to carry it over here. Because it is a Q&A site with heavy google traffic from everywhere. It is not a forum where we exchange ideas or opinions. Just take your time and look at the questions' brevity in general. – percusse Mar 18 '12 at 15:12

You need to decide if you coding in TeX or you still thinking in another computer language. I can gather from your comments such as "...drives me nuts", "...things go to hell in a handbasket real quick" that you have a hard time adapting. So I would suggest rather think in "Lua", move all your coding into the Lua part.

Here is an example that justs does and calculates happy numbers that might also make you a bit happier:)

All the typesetting has been moved onto a function in this case \boxit thus having a good separation of concerns; think the same way for your table, post a minimal and maybe the community can take it up from there.

\lstloadlanguages{[LaTeX]TeX, [primitive]TeX,Pascal}
\usepackage{luacode} % loads luatexbase as well
      showspaces=false,  % shows spacing symbol

-- example adapted from
-- http://rosettacode.org/wiki/Happy_numbers
function boxit(color, var, s)
  return "\\fbox{\\strut\\color{violet} "..var.."} "
function digits(n)
  if n > 0 then return n \% 10, digits(math.floor(n/10)) end
function sumsq(a, ...)
  return a and a ^ 2 + sumsq(...) or 0
local happy = setmetatable({true, false, false, false}, {
      __index = function(self, n)
         self[n] = self[sumsq(digits(n))]
         return self[n]
      end } )
i, j = 0, 8
   i, j = happy[j] and (tex.sprint(boxit(violet, j, " ")) or i+1) or i, j + 1
until i == 17 --or j > 999
  • I also can't use luacode as I get errors. If I change luadirect to luaexec it fails to work even on an empty block. I've moved many functions I use to an external lua file but I like to work in one file as I don't have to switch back and forth(which is better for learning as it is more efficient(or should be)) – Uiy Mar 18 '12 at 14:56
  • @Uiy Hang in there! Leave your package aside for a day or two and put effort to work out a few long examples in (La)TeX. Read something that has a beginning and an end and then tackle the package again. Or go for all Lua as shown in my post. That way you contain the problems and you can handle them later rather than stop the programming flow. – Yiannis Lazarides Mar 18 '12 at 15:01
  • @Uiy I use a basic file as above to test (it is all in one file) and the output is at the bottom of the box, nicely typeset. When it works I move it onto the main files. – Yiannis Lazarides Mar 18 '12 at 15:02
  • Thats what I do ;) But the problem is I have to escape everything in the tex file and then remove the escapes when I copy it over to the lua file. Luckily I don't have much more left to do... I hope. Lualatex is pretty cool but I don't have any idea why luacode is broke for me ;/ I'll make a post about it. – Uiy Mar 18 '12 at 15:06
  • @Uiy I agree! rather make a post with a full MWE that shows the problem. Also read through \usepackage{luacode}. – Yiannis Lazarides Mar 18 '12 at 15:20

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.