GeneralDifference between NewDocumentCommand and cs_new

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
stridder
Posts: 6
Joined: Sun Mar 13, 2016 9:43 am

Difference between NewDocumentCommand and cs_new

Post by stridder »

Hello,

What the difference between \NewDocumentCommand (and relatives) and \cs_new:Npn (and relatives)?

As fas as I understood both macros are introduced in LaTeX3 and both for the purpose of creating new macros. I am not talking about different syntax.
Do they have different use cases?

Maybe \cs_new:Npn is for low-level use only or otherwise?

Thank you.
Last edited by cgnieder on Mon Apr 11, 2016 7:25 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Difference between NewDocumentCommand and cs_new

Post by josephwright »

The idea of separate layers is very important in the work being done by the LaTeX3 Project. \NewDocumentCommand and relatives are for defining document level commands, so 'things you use in a typical LaTeX file'. On the other hand, \cs_new_protected:Npn and so on are 'code level' functions for programming. The idea is that you use \NewDocumentCommand as the 'glue' between the syntax you want in a document and the programming done using \cs_new_protected:Npn.
Joseph Wright
Post Reply