2

I'm trying to mention below path... but I am getting an error.

Select \textbf{root directory} and select the folder 
\textbf{Diagnostics_Example} from path \textit{C:\Users\harshalb\K-DCP 
Projects\OTX}

Please guide me as I'm new to Latex.

Andrew Swann
  • 95,762

1 Answers1

6

I would strongly advise you to either use \verb or the url package.

The \verb command is designed for typesetting entities that include characters that are special in LaTeX and it respects spaces in its argument.

Sample output

\documentclass{article}

\begin{document}

Select \verb+root directory+ and select the folder
\verb+Diagnostics_Example+ from path
\verb+C:\Users\harshalb\K-DCP Projects\OTX+.

\end{document}

As you can see the syntax is slightly non-standard, writing

\verb+...+

where + can be replaced by any character not in the argument.

The disadvantage of \verb is that it will not allow its argument to break over lines. The url package removes that restriction:

Sample url output

\documentclass{article}

\usepackage[obeyspaces]{url}

\begin{document}

Select \url+root directory+ and select the folder
\url+Diagnostics_Example+ from a path on your system such as this one:
\url+C:\Users\harshalb\K-DCP Projects\OTX+.

\end{document}

Note the use of the obeyspaces option to respect spaces in the arguments. The url package allows you to change the style/font of urls too, e.g. \urlstyle{rm} will use the text font. See the package's documentation either via texdoc url on your system or at https://www.ctan.org/pkg/url?lang=en .

As @Mico mentions:

  1. You may wish to consider adding the package options hyphens and/or spaces to allow line breaks at those characters.

  2. The url package also provides the \path command, which is a version of \url which does not get converted to an active link if you have the hyperef package loaded.

Andrew Swann
  • 95,762
  • 2
    +1. The url package also provides the macro \path, which essentially behaves like \url except that the macro's argument won't be made into a hyperlink in case the hyperref package is loaded as well. A separate comment: To allow linebreaks at hyphens and spaces, I'd also specify the options hyphens and spaces while loading the url package. – Mico Sep 21 '17 at 07:29
  • @Mico Indeed - answer extended. – Andrew Swann Sep 21 '17 at 08:11
  • @AndrewSwann thank you very much for ur valuable suggestion. – Harshal Bonde Sep 22 '17 at 08:37