# Tag Info

11

\verb has no effect on tokens (even if you expanded \FileName), so you want something more like this \def\FileName{A_B} \documentclass{article} \usepackage[T1]{fontenc} \begin{document} \texttt{\detokenize\expandafter{\FileName}} \end{document}

7

With tcolorbox and the listings library you can show the verbatim form of your equation. you have just to add listing side text in the option of tcblisting environment \documentclass{article} \usepackage{tcolorbox} \tcbuselibrary{listings} \begin{document} \begin{tcblisting}{listing side text} $f(x)=\frac{1}{\ln x - x^2}$ \end{tcblisting} ...

5

You can use command \verb## and environment verbatim like this: \documentclass{article} \begin{document} \verb#\textbf# is used to make the font bold, for example i could write: \verb#\textbf{This Is Boldface!}#, resulting in \textbf{This Is Boldface!} When you have multiple lines of code, it is best to use environment \verb#verbatim#: \begin{verbatim} ...

4

It will be incomplete if listings is not mentioned for such a purpose. \documentclass{article} \usepackage{listings} \lstset{ % language={[LaTeX]TeX}, basicstyle=\small\ttfamily, } \begin{document} \lstinline{\textbf} is used to make the font \textbf{bold} \lstinline{\textit} is used to make the font \textit{italic} \end{document}

4

You don't explain your reasons why you would want to use control sequences within a listing, but I can think of at least one: maintainability. That way, if you change the definition of your macro, that change gets reflected everywhere the macro is used within your listings, just like what happens in the "normal text" of your TeX file. Simple solution As ...

4

There's no easy solution for this. The only way not to collect sectional commands is to not collect the file. To do that, Go to "Options" -> "Options Interface" and double-click the "Input Directives" branch: A local copy of Input.ini gets opened. In this file remove the lines DIRECTIVE="\lstinputlisting[????]{?}" EXTENSION="*;.tex" ...

3

If you really don't want to use any additional code (why not?, I'd use varwidth here) then you can just use a normal minipage but you would have to tell it how many characters are on the longest line. \documentclass{article} \begin{document} \begin{center} hello world \end{center} \begin{center}\ttfamily\sbox{0}{a}% \begin{minipage}{24\wd0}% 24 ...

3

In the manuals of my packages I use a custom package for code and examples which uses a combination of listings and mdframed for displaying the code. I haven't really intended to make it public (which is why it has a lot of quirks which should be addressed some time...) but it is available on CTAN. However: usage at your own risk! \documentclass{article} ...

2

\documentclass{article} %\usepackage[T1]{fontenc} \begin{document} Hi! you can do: \texttt{\textbackslash textbf} is used to make the font \textbf{bold} \texttt{\textbackslash textit} is used to make the font \textit{italic} or: \textbackslash\texttt{textbf} is used to make the font \textbf{bold} \textbackslash\texttt{textit} is used to make the font ...

2

We can do this with listings package, putting arabic words inside symbols defined with escapeinside like this : \documentclass[12pt,a4paper]{article} \usepackage{listings} \usepackage{polyglossia} \setmainlanguage[numerals=maghrib]{arabic} \setotherlanguage{english} \newfontfamily\arabicfont[Script=Arabic,Scale=1.2,AutoFakeSlant=-0.02]{Traditional Arabic} ...

2

I am not sure if this works in ConTeXt but in LaTeX I have been using this to include my C++ code. You should be able to change this to work with C as well. Preamble: \usepackage{listings} \usepackage{textcomp} \definecolor{listinggray}{gray}{0.9} \definecolor{lbcolor}{rgb}{0.9,0.9,0.9} \lstset{ %backgroundcolor=\color{lbcolor}, tabsize=4, % ...

1

This ConTeXt Garden page lists the pret-c module. So the following should work. \installprettytype[C][C] \definetyping[C][option=C, tab=4] % defines \startC as shortcut for \starttyping[option=C] \definetype[typeC][option=C, tab=4, style=tt] % defines \typeC \definecolor[Ccomment][darkblue] \starttext bla bla \typeC{int main(){}} bla bla \startC int foo = ...

1

The error is because you have to declare the frame as [fragile] due to the presence of verbatim code. To get a good fit you can reduce the size of the font and you can use another font. To reduce the size of the font you can use \footnotesize or \scriptsize in the frame. If you add \usepackage[scaled]{beramono} to the preamble it will use the beramono font ...

1

With columns=fixed and columns=flexible, the listing is built inserting each character in a box 0.6em wide for fixed and 0.45em for flexible (the default value can be changed via basewidth). Using these two types is meaningless when the font has fixed width glyphs, like Courier or Computer Modern Typewriter, because for these fonts the interword space is ...

1

The verbatimbox package can help. It also works on true verbatim, unlike a \texttt alternative. \documentclass{article} \usepackage{verbatimbox} \begin{document} \verb?x^2 + 1 + \alpha? \par \begin{verbbox}x^2 + 1 + \alpha\end{verbbox} \fbox{\theverbbox} \end{document}

1

you could use \texttt{x\char`\^2 + 1}

Only top voted, non community-wiki answers of a minimum length are eligible