How to keep symbols, slash, ... in your document? [closed] - latex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I want to keep all the symbols in my following text in LaTeX. but I don't know which syntax I should use to keep them. Can anybody give a suggestion?
/forest # search for forest
/<\/way> # find the tag </way>
v # start the visual mode
?<way # find the begin of the tag -> mark <way> until </way>
D # delete that tag

Just put them in verbatim environment, like this:
\begin{verbatim}
...
things you want to keep them as is
...
\end{verbatim}
For inline mode, you can use \verb command:
\verb=...things you want to keep them as is...=
Check out here for more info:
[...] If you use the verbatim environment, everything input between the begin and end commands are processed as if by a typewriter. All spaces and new lines are reproduced as given, and the text is displayed in an appropriate fixed-width font. Any LaTeX command will be ignored and handled as plain text. This is ideal for typesetting program source code. [...]

Related

Is there a way to label Python code in LaTeX? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
We have made a few examples of code in Python and inserted them into a LaTeX/overleaf document. We are currently looking into making a label for them, so they can be referenced at various points, however using the \begin(python) doesn't seem to allow us to add a \label{}, which works and can be referenced.
A similar example of what we are looking for would be
\documentclass[11pt,a4paper,twoside,openany,english]{book}
\usepackage{pythonhighlight}
\begin{python}\label{SO-test}
value_a = 1
value_b = 2
print(value_a + value_b)
\end{python}
Any tips or tricks are appreciated.
Behind the scenes the pythonhighlight uses the much more common listings package. The listings package allows you to add a caption and label as optional argument of the lstlistings environment.
However even though the pythonhighlight sets up its python environment with the possibility to add an optional argument, it never uses this argument. Thus the information is never forwarded to the lstlistings environment.
To work around this, you can set up your own environment:
\documentclass[11pt,a4paper,twoside,openany,english]{book}
\usepackage{pythonhighlight}
\lstnewenvironment{mypython}[1][]{\lstset{style=mypython,#1}}{}
\begin{document}
\begin{mypython}[caption={some text to produce a caption},label=SO-test]
value_a = 1
value_b = 2
print(value_a + value_b)
\end{mypython}
Reference: \ref{SO-test}
\end{document}
I tried to just include this in a comment, but I'm too new to stack overflow.
Have you tried just using regular verbatim instead of making it explicitly python? Is there something wrong with that?
\begin{verbatim}
Text enclosed inside \texttt{verbatim} environment
is printed directly
and all \LaTeX{} commands are ignored.
\end{verbatim}
I also saw this thing about minted in their library.
It makes a reference to \begin{minted}{python}
https://www.overleaf.com/learn/latex/Code_Highlighting_with_minted

How can I highlight text in latex [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
How can i highlit text in latex.
Thank you.
As is pictured here(in red circle):
If you mean making the text bold by Highlighting you can use \textbf for making the text bold but highlighting has a different general meaning that is implemented by \hl keyword.
\documentclass{report}
\usepackage{color} % for the command \textcolor
\usepackage{soul} % for the command \hl
\begin{document}
\hl{foo}
\hl{\textbf{foo}}
{my garden }
\textbf{black}{foo}
{my good job}
\textbf{\textcolor{red}{\hl{foo}}}
\textcolor{red}{\textbf{\hl{foo}}}
\end{document}
this is the result :
As you can see the word "black" is highlighted the way you desired.
The word "foo" is highlighted in the general meaning of highlighting.
This links look useful:
Insert symbols inside verbatim mode LaTeX
Putting math inside a verbatim environment without altering the formatting
If you just wanted graph.exe I would suggest using \begin{verbatim} graph.exe \end{verbatim} or \verb+graph.exe+ .
However you want to use the <..> expression which can be created with $ \langle ... \rangle $ . The $..$ indicates inline math mode. Those two links discuss getting verbatim text in math environments.
I think tex.stackexchange.com will be more helpful rather than stack overflow.

Latex Hyperref with Pagenumber [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
i want to use hyperref in my latex document to link to labels
and i want to show the page number of the label.
so for example:
\label{subsubsec:foo}
\hyperref[subsubsec:foo]{See foo on page ???}
How can i get the page number of the label?
First note that hypperef is only used to create hyperlink in PDF document (see https://en.wikibooks.org/wiki/LaTeX/Hyperlinks ).
In order to get the page number of a label, use the \pageref command and provide it the name of the label as first argument (see https://en.wikibooks.org/wiki/LaTeX/Labels_and_Cross-referencing ).
Your code should be:
\usepackage{hyperref}
[...]
\label{subsubsec:foo}
[...]
See foo on page \pageref{subsubsec:foo}
As a consequence of the inclusion of the hypperef package, hyperlinks will be present in the generated PDF document.

How to write URLs in Latex? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
How do you write a URL in Latex?
The subscripts and everything else make the font look very strange when it compiles.
You can use \url
\usepackage{hyperref}
\url{http://stackoverflow.com/}
You just need to escape characters that have special meaning: # $ % & ~ _ ^ \ { }
So
http://stack_overflow.com/~foo%20bar#link
would be
http://stack\_overflow.com/\~foo\%20bar\#link
Here is all the information you need in order to format clickable hyperlinks in LaTeX:
http://en.wikibooks.org/wiki/LaTeX/Hyperlinks
Essentially, you use the hyperref package and use the \url or \href tag depending on what you're trying to achieve.
A minimalist implementation of the \url macro that uses only Tex primitives:
\def\url#1{\expandafter\string\csname #1\endcsname}
This url absolutely won't break over lines, though; the hypperef package is better for that.

Preventing \texttt LaTeX tag from letting its content passing over the margin [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
In my report, I'm writing some class names or variable names inside of a paragraph, and I want these names to be rendered in a monospace font.
Example:
This is my class name: \texttt{baseAdminConfiguration}.
Sometimes when the single word inside of the \texttt tag is rendered at the end of a line, the word does not go to the next line, and there is no break in it neither: the end of the word passes over the margin.
How should I handle such a case?
Cheers.
This hasn’t got much to do with \texttt. The word is simply too long, and LaTeX doesn’t know how to hyphenate it. You can tell it how to do this manually, by declaring hyphenation rules:
\hyphenation{base-Admin-Configuration}
The \hyphenation command may take arbitrarily many words, separated by whitespace.
Alternatively, if this doesn’t the trick, you can introduce manual hypenation hints in the text:
This is a long text that uses the word \texttt{base\-Admin\-Configuration) …
Only the actual hyphenation will be displayed – unused so-called discretionary hyphens (\-) will not be displayed so you can freely sprinkle your text with them, if necessary.
[Read more about hyphenation in LaTeX]
To prevent LaTeX from overflowing lines in principle, the whole paragraph can be wrapped in a sloppypar environment (thanks to Will for pointing this out in the comments):
\begin{sloppypar}
Some text …
\end{sloppypar}
This manipulates the parameters of the line-breaking algorithm (in particular, \tolerance). The downside: this can lead to very ugly spacing. Alternatively, \tolerance and other internal parameters can be manipulated directly – the TeX FAQ shows how.
The solution is quite simple: use the url package and replace the texttt command with the path command.
I found out that here
https://tex.stackexchange.com/questions/299/how-to-get-long-texttt-sections-to-break
in the post of Will Robertson.
Cheers

Resources