A magistrate has ordered a homeless man who allegedly punched a baby in a pram in central Sydney to be admitted to hospital for a psychiatric assessment.

Nicholas Bolas, 28, is accused of punching the 16-month-old girl as she sat in her pram next to her parents at a cafe near Central Station about 11:30am on Thursday.

Bolas was arrested shortly afterwards and charged with assault occasioning actual bodily harm.

He was remanded in custody and appeared today in Sydney's Central Local Court.

Bolas appeared topless in the dock with corrective services officers telling the court he refused to put on a shirt for the hearing.

The court heard Bolas was involuntarily admitted to Sydney's St Vincent's hospital for acute psychosis between May 5 and 11.

Bolas was discharged on May 13.

The court also heard an arrest warrant had been issued in Queensland after Bolas left without permission from a mental health unit there.

Bolas' solicitor argued the 28-year-old should be dealt with under the Mental Health Act.

But the prosecutor argued Bolas did not fit the definition of a mentally ill person, as defined in the act.

Magistrate Les Mabbutt asked Bolas whether he wanted to go to hospital to which he replied, "No, not really, I'm fine".

But Bolas could not say when he last took medication for his psychosis.

Magistrate Mabbutt ordered Bolas be admitted to St Vincent's hospital for a psychiatric assessment.

He said Bolas would return to the court system if he was found to be mentally fit.