GeneralDisplay backtick character

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
zaxx
Posts: 3
Joined: Thu Feb 28, 2008 5:30 pm

Display backtick character

Post by zaxx »

I am working on a LaTex document and I am placing a piece of code in a verbatium block. This code comes from a language where the <backtick> (character below the tilde) is used. To print this code snippet I need to be able to print the backtick code and not have it show up as the open quotation marks. (standard backtick behaviour). How do I go about this?

Code I am inserting:

\begin{verbatim}
`include "file1"
`include "file2"
\end{verbatim}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Display backtick character

Post by localghost »

I suggest to use the listings package to get rid of this problem.


Best regards
Thorsten
zaxx
Posts: 3
Joined: Thu Feb 28, 2008 5:30 pm

Re: Display backtick character

Post by zaxx »

Listings will not work as it does not support the language I am trying to post a snippet of. (Verilog HDL)
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Display backtick character

Post by Juanjo »

The following code does exactly what you want, at least in my computer:

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}

\begin{document} 
\newcommand{\BInclude}{\symbol{0}include}
\begin{Verbatim}[commandchars=ç¿?]
    çBInclude "file1"
    çBInclude "file2"
\end{Verbatim}
\end{document}
You may want to change the command chars if any is used in the programming language. The manual of the fancyvrb package can be found here
zaxx
Posts: 3
Joined: Thu Feb 28, 2008 5:30 pm

Re: Display backtick character

Post by zaxx »

Juanjo - thank-you for the reply, what you suggested works great! Much appreciated.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Display backtick character

Post by Juanjo »

Reading the manual of the listings package for a diferent matter, I realized that the problem here can be solved as follows:

Code: Select all

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{listings}

\begin{document}
\begin{lstlisting}[upquote=true]
`include "file1"
`include "file2"
\end{lstlisting}
\end{document}
The fontenc and textcomp packages are also required. This approach seems advantageous compared with that based on fancyvrb, since you can benefit from the facilities provided by listings to format the code.
benjaminevans82
Posts: 2
Joined: Thu May 01, 2008 11:23 pm

Re: Display backtick character

Post by benjaminevans82 »

This topic is very helpful but what I need is a backtick in line with other text which is in \texttt format.
The current solution puts everything into the new format, or just the backtick but with a blank line above and before it. What I really need is a command like \textbackslash something like \textbacktick. Could this be built into LaTeX 3 do you think?

Any help would be appreciated.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Display backtick character

Post by Stefan Kottwitz »

Hi benjaminevans82,

welcome to the LaTeX Community board!
Try:

Code: Select all

\`{}
Stefan
LaTeX.org admin
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Re: Display backtick character

Post by Juanjo »

Perhaps you may also want to try the \textasciigrave command provided by the textcomp package.
vo1stv
Posts: 1
Joined: Sat Nov 28, 2009 5:44 pm

Display backtick character

Post by vo1stv »

I feel your pain but thanks to the LaTeX documentation project (http://www.latex-project.org/guides), I have an answer for you:


Forget textcomp and fontenc... they are not required. Instead, use the following:

Code: Select all

\lstset{language=Verilog,literate={`}{{$^{\backprime}$}}1}
\lstinputlisting{verilog.v}
Post Reply