Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizGeneral Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
As described in the documentation of the listings
package, you have to define the caption
and label
in the options of the lstlisting
environment. This is required because any text within lstlisting
is typeset, so your code prints \label{phpheg}
in the PDF, instead of calling that as a LaTeX command.
\documentclass{article}
\usepackage{listings}
\begin{document}
See Listing~\ref{phpheg} for details.
\begin{lstlisting}[caption={PHP Code},label=phpheg]
$id = addslashes($_GET['id']);
\end{lstlisting}
More text.
\end{document}
Note: as Werner says in his comment, as everything between \begin{lstlisting}
and \end{lstlisting}
is printed, thus indented code is also typeset indented. As a work-around, you can (and should) write the listing without any indention (as above).
As proposed by MaxNoe, you can use the lstautogobble
package as a workaround: simply add \usepackage{autogobble}
and set autogobble=true
in the settings of lstlistings
.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
manpreet
Best Answer
2 years ago
Hello can somebody please show the correct way to display my source code in Latex
The following
code
I want to display asphp code
How can I display the above
code
inLatex
assource code
? In My document .I tried the below but get an error about a label not yet been referenced