2

I would like to set the text format of the document as the format for the listing. The words in the listing accross my tex document have a bigger space between the characters. I want them to the have the exact format and size as the normal text(the only exception is the keywords). Can anyone give me some hints? Thank you in advance.

\documentclass[ngerman,12pt,a4paper]{report}
\usepackage{listings}



\lstdefinelanguage{sparql} {
morekeywords={LIMIT, PREFIX, GRAPH, AS, WITH, RECURSIVE, CONSTRUCT, FROM, NAMED, SELECT, WHERE, DISTINCT, FILTER, ORDER, BY, ASC, REGEX, DSC},
sensitive=true
}

\begin{document}

\lstset{language=sparql}
\begin{lstlisting}[label=lst:rdf-rdfs-example, captionpos=b, caption=N-Triple illustration for the Figure \ref{fig:RDF-RDFS}, basicstyle=\small,float,floatplacement=H]

PREFIX ex: <http://example.com/>

RDFS: 
<http://example.com/person> <rdfs:subClassOf> <http://example.com/customer> . 
<http://example.com/laptop> <rdfs:subClassOf> <http://example.com/product> .
<http://example.com/hasBought> <rdfs:domain> <http://example.com/person> .
<http://example.com/hasBought> <rdfs:range> <http://example.com/product> .

RDF: 

<http://example.com/persons/1> <rdf:type> <http://example.com/customer> .
<http://example.com/laptops/2> <rdf:type> <http://example.com/laptop> .
<http://example.com/persons/1> ex:hasBought <http://example.com/laptops/2> .
\end{lstlisting}
\section{RDF Frameworks} 
The two major RDF frameworks that have been used for the evaluations presented in this Thesis are Jena \cite{carroll2004jena} and Sesame \cite{broekstra2002sesame} (recently known as RDF4J \footnote{\url{http://rdf4j.org}}). They are both Java frameworks for storing and querying RDF data and consist of parsers and writers for most types of RDF serializations.
\end{document}

example page

2

The spacing in listings is determined by the column alignment (as described in section 2.10 of the documentation). So you can use the columns=fullflexible to achieve the look you want:

\documentclass[ngerman,12pt,a4paper]{article}
\usepackage{listings}
\usepackage{url}

\lstdefinelanguage{sparql} {
morekeywords={LIMIT, PREFIX, GRAPH, AS, WITH, RECURSIVE, CONSTRUCT, FROM, NAMED, SELECT, WHERE, DISTINCT, FILTER, ORDER, BY, ASC, REGEX, DSC},
sensitive=true,
columns=fullflexible
}

\begin{document}

\lstset{language=sparql}
\begin{lstlisting}[label=lst:rdf-rdfs-example, captionpos=b, caption=N-Triple illustration for the Figure \ref{fig:RDF-RDFS}, basicstyle=\small,float,floatplacement=H]

PREFIX ex: <http://example.com/>

RDFS: 
<http://example.com/person> <rdfs:subClassOf> <http://example.com/customer> . 
<http://example.com/laptop> <rdfs:subClassOf> <http://example.com/product> .
<http://example.com/hasBought> <rdfs:domain> <http://example.com/person> .
<http://example.com/hasBought> <rdfs:range> <http://example.com/product> .


\end{lstlisting}
\section{RDF Frameworks} 
The two major RDF frameworks that have been used for the evaluations presented in this Thesis are Jena \cite{carroll2004jena} and Sesame \cite{broekstra2002sesame} (recently known as RDF4J \footnote{\url{http://rdf4j.org}}). They are both Java frameworks for storing and querying RDF data and consist of parsers and writers for most types of RDF serializations.
\end{document}

output of code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.