Hi,
I have made the symbol, with correct numbering as per subckt file.
I then pasted the subckt file into the LTspice schem.
I then right clicked the symbol and made "prefix" be "x" and "value" be "LM311".
...Aaah...maybe i have gone outside the common mode range for inputs...just tried square wave 2v to 3v and its working. Sorry.
Even so, wow, i didnt realise LM311 was that useless as not to be able to accept a 0v,5v square wave input when its given a 5V single supply?
The LM311 is about 50 years old, maybe more.
It was and still is within its limits, a great device with the available, all-bipolar semiconductor technology.
You just have to (gasp) follow the data sheet limits, which is 0.5V above the lower supply voltage (ground here). and 2V below the upper supply voltage (below).
The LM339 comparator has -1.5V upper limit, but the input can go down to zero when powered from a single 5V supply.