Tag Info

New answers tagged

1

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


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

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 ...


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" ...


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 ...


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 ...


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 ...


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}


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} ...


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 = ...


0

DISCLAIMER: This doesn't answer the question, I misunderstood it and thought the interest was on MkII. As I say at the bottom of the answer I don't know what's the system in MkIV (nor in MkII :D). Just copying from the link in the contextwiki you shared \input verb-c.mkii \setupcolors[state=start] \setuptyping[option=color] % define the colors to fit ...


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, % ...


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} ...


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} ...


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 ...


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} ...


1

Your example can't break at the ? because the first definition defines the hyphenchar for cmtt in T1 encoding (and you use lmodern) and the second defines \mytexttt but your document uses \texttt. If you replace \texttt with \mytexttt or drop lmodern and use \usepackage[T1]{fontenc} or drop lmodern and use \DeclareFontFamily{OT1}{cmtt}{\hyphenchar ...


3

In addition to specifying the option [fragile] when starting the frame, you will need to issue the command \scriptsize -- for a 30% linear reduction in font size -- in order to make the verbatim material fit in the frame. % !TEX encoding = UTF-8 Unicode \documentclass{beamer} \mode<presentation> \usetheme{Madrid} \setbeamercovered{transparent} ...



Top 50 recent answers are included