TransWikia.com

redefine path with trailing backslash

TeX - LaTeX Asked by Micha on April 16, 2021

The following MWE works fine:

documentclass{article}
usepackage{url}
renewcommand{path}[1]{hidden for privacy}
begin{document}
path{C:UserJohn Doe}
end{document}

With a trailing backslash (path{C:UserJohn Doe}) it won’t compile. I’ve got

Runaway argument?
{C:User John Doe} end {document} 
! File ended while scanning use of path.

How can I redefine path that it works with trailing backslashes, too?

One Answer

You can use xparse and its v type argument specifier. If your LaTeX installation is 100% up to date, xparse is already build into latex

RenewDocumentCommandpath{v}{hidden for privacy}

Full MWE:

documentclass{article}
usepackage{url}
%renewcommand{path}[1]{hidden for privacy}
RenewDocumentCommandpath{v}{hidden for privacy}
begin{document}
path{C:UserJohn Doe}
end{document}

Similar with xparse explicitly loaded

documentclass{article}
usepackage[T1]{fontenc}
usepackage{xparse}
usepackage{url}
%renewcommand{path}[1]{hidden for privacy}
RenewDocumentCommandpath{v}{»Path hidden for privacy«}
begin{document}
path{C:UserJohn Doe}
end{document}

Correct answer by daleif on April 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP