In LaTeX text, I sometimes need 'unpaired' parenthesis - ( without ) or vice versa; however, in such a case, delimiter check macro reports error. I found a simple solution: \symbol{40} and \symbol{41}, which aren't recognized as delimiters. The same works for brackets [ and ] (decimal codes are 91 and 93 respectively), but doesn't work for braces { and }. Their codes are 123 and 125 respectively, but \symbol{123} and \symbol{125} produce something like dash and quote. I use fontenc LCY, trying both text and math modes.
I've found a solution:\textbraceleft and \textbraceright, but why \symbol doesn't work in such a case?
Found it! This first code
\documentclass[border=5mm]{standalone}
\begin{document}
\symbol{123} and \symbol{125}
\end{document}
gives
as output, while
\documentclass[border=5mm]{standalone}
\usepackage[T1]{fontenc}
\begin{document}
\symbol{123} and \symbol{125}
\end{document}
gives this output instead:
Adding
\usepackage[T1]{fontenc}
provides the desired font encoding (fontenc package).
A (not-so-further) reading suggestion: font encoding vs. input encoding.
Related
I'm having issues turning this word equation into a LaTex equation. It's coming out looking dodgy, please help!
I added a screen shot of the equation I want, and what I end up getting when I copy and paste into LaTex:
WORD:
LATEX CODE:
\mathrm{=\ }\mathrm{C}_\mathrm{0}\mathrm{[1-}6(Dt)1/2aπ2-3Dta2] + 12(Dt)1/2an = 1∞exp(na(Dt)1/2)
and therefore nothing comes out and LaTex doesn't let me run it.
This is absolutely not a proper LaTeX equation code. I don't know what you know about LaTeX, but you cannot just copy and paste from Word or any software to you LaTex editor. Plus, you need to provide your full code for anyone being able to help you.
Anyway, running this MWE should work :
\documentclass[11pt, a4paper, twoside]{report}
% ===== PACKAGES DECLARATION =====
\usepackage{mathtools} % Replaces amsmaths + more features
\usepackage{amsfonts} % Maths fonts package
% ===== DOCUMENT BODY =====
\begin{document}
\begin{equation} % optional : use the "equation*" environment to remove equation number
% optional : use traditional math font by removing the \mathrm{} command
\mathrm{X = C_0 \left[ 1 - \frac{6(Dt)^{1/2}}{a \pi^2} - \frac{3Dt}{a^2}\right] + \frac{12(Dt)^{1/2}}{a} \sum_{n=1}^\infty \exp\left(\frac{na}{(Dt)^{1/2}} \right)}
% optional : remove auto-sized brackets by removing the \left and \right commands
\end{equation}
\end{document}
As written in the code, you may want to remove the equation number and the big auto-sized brackets (that are more readable in my opinion). Just remove the corresponding commands. Also, you should consider using the "normal" math font and not the roman one that is clearly different from the text and helps the reader to separate equations from inline small expressions you could insert in your document.
One first sketch:
\documentclass{article}
\begin{document}
\[
C_0\left[1-\frac{6(Dt)^{\frac{1}{2}}}{a\pi^2}-\frac{3Dt}{a^2}\right]+%
\frac{12(Dt)^{\frac{1}{2}}}{a}\sum^{\infty}_{n=1}%
\exp\left(\frac{na}{(Dt)^{\frac{1}{2}}}\right)
\]
\end{document}
No packages required. The output:
Than you can tune the math fonts and anything else.
I'm using latex to model a few functions using Z-Notation, however, I'm having issues showing a string for output. In this reduced example code, the text in the quotes has a different formatting from what I would expect. What can I use to keep the formatting the text inside the quotes to be the same in the code snippet?
Edit: The overDraftMessage should be messageOutput, missed changing this when creating a reduced example.
\documentclass{article}
\usepackage{oz} % oz or z-eves or fuzz styles
\begin{document}
\begin{schema}{function}
messageOutput!: $STRING$ \\
\where
messageOutput! = ''Output looks strange.'' \\
\end{schema}
\end{document}
Solution from #lburski works, but tilde is not for this purpose. It should be used to make hard space (non-breaking space). To write space in whitespace insensitive environments, you need to escape it - write backslash before every space: ''Output\ looks\ strange''.
If you want a space between the words on your string ''Output looks strange.'' then try putting a tilde '~' between those words. So you string ends up being ''Output~looks~strange.''
I would like to include some Julia source in a LaTeX doc. I am familiar with the 'listings' package, and have crafted a decent 'lstdefinelanguage'. But I am having trouble with non-ASCII characters in the jl. I have played around with various 'lstset' and 'inputenc' options like 'extendedchars' and 'utf8' to no avail. I am using TeXShop on a Mac. Has anyone cracked this?
You can use literate option although it requires some set-up work. Here is a MWE:
\documentclass{article}
\usepackage{listings}
\usepackage{courier}
\lstset{basicstyle=\ttfamily}
\lstset{literate=
{δ}{{$\delta$}}1
{ϵ}{{$\epsilon$}}1
}
\begin{document}
\begin{lstlisting}
function f()
ϵϵϵϵϵ = 1
xxxxx = 3
δδδδδ = 2
ϵ + x + δ
end
\end{lstlisting}
\end{document}
I use the listings package to insert source code. I would like to print all keywords uppercase in the output, regardless of the case in the input.
The manual states that
keywordstyle=[number][*]style
produces just what I want. However the following (almost) minimal example does not work.
if I set keywordstyle to "[1][]{\bfseries}" I end up with "[]" in front of every keyword
and "[*]{\bfseries}" gives me an asterisk in the start of the document.
I also tried "\MakeUppercase" and "{\MakeUppercase}" for keywordstyle which resulted in several errors, the first being:
! Incomplete \iffalse; all text was ignored after line 11
Minimal example:
\documentclass{article}
\usepackage{listings}
\lstdefinelanguage{KA_assembler}
{morekeywords={add,and,or,xor},
keywordstyle=[1][*]{\bfseries},
sensitive=false,
}
\lstset{language=KA_assembler}
\begin{document}
\begin{lstlisting}
and %r1, %r2
xor %r2, %r3
and %r4, %r5
\end{lstlisting}
\end{document}
I use Miktex for compilation of the tex files. So how do I force uppercase for Keywords?
In the manual, the brackets around the * look a bit different then the brackets around number. The reason is that the brackets around * are not meant to be used in the latex code, they just indicate that the presence of the * is optional. So try
keywordstyle=[1]*\bfseries
or
keywordstyle=*\bfseries
- it worked for me.
Following on from this question, I'm totally stumped on getting LaTeX to give me a tilde when I'm in verbatim mode. It has to be a tilde because it's the type of a function!
sig symm : (Board, [(Int, Int)]) ~> Bool
Standard methods for displaying a tilde are printed verbatim, of course..
Any suggestions?
An edit to clarify: Typing a ~ in verbatim mode gives an accent above a blank space. I'm after a tilde as it appears at the beginning of this sentence.
If there are some characters that do not occur in your input, you can use fancyvrb and its commandchars option to insert TeX commands within verbatim text:
\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\newcommand{\mytilde}{$\sim$}
\begin{Verbatim}[commandchars=\\\{\}]
sig symm : (Board, [(Int, Int)]) \mytilde> Bool
\end{Verbatim}
\end{document}
See the documentation of fancyvrb for more.
Perhaps you should look at: LaTeX package to do syntax highlighting of code in various languages which has suggestions for typesetting code...
I assumed that listing would do it for you, but failing that alltt and fancyvrb are alternatives to verbatim. See this search on CTAN for other possibilities.
If you are using listing command, you can set the tilde to be literal. Likt this.
\documentclass
\usepackage{listings}
\lstset{
literate={~} {$\sim$}{1} % set tilde as a literal (no process)
}
\begin{document}
\begin{lstlisting}
~
\end{lstlisting}
\end{document}
\begin{verbatim}
~
\end{verbatim}