Add a custom word to a cross reference in LaTex - latex

Good morning!
I've been searching for a time but I can't reach a solution to my problem. I'm writing my master thesis, and I want to add custom words to my references, I mean, if I want to ref the only table in my document (\label{table:test} for example), I usually do \ref{table:test}, getting as a result just a clickable number 1.
However, I need to set a global option in order to, always I refer to a table, for example, I get {custom word} 1(1 for the first table). This custom word surely will be Table, but I can desire to use Figure(in English) or Imagen (in spanish), for ref figures.
Thanks you very much in advance!

The cleveref package will automatically add the correct words and adapt to the language of your document:
\documentclass[spanish]{article}
\usepackage{babel}
\usepackage{hyperref}
\usepackage[noabbrev,nameinlink]{cleveref}
\begin{document}
\begin{figure}
\caption{content...}
\label{key}
\end{figure}
\cref{key}
\end{document}

Related

Latex - how can I make a text to stand out more?

I'm designing my diploma thesis and would like to make a big question mark to every problem and a exclamation mark to every solution. It should like like this:
Do you know any Latex-Libraries to accomplish that behaviour? If there is no such library I would be more than happy if you could help me getting started writing my own Latex-Command.
Here is one basic approach. No packages are involved.
A particular thing about your layout is the use of the margin, correlated with that line of text. One way about it is to define a simple environment, which uses Latex command for margin notes, \marginpar. Then you can also set up fonts as you please, within this environment. Below I also insert an unrelated margin note, as an example in case you are not familiar with those.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\newenvironment{Q} {\hspace{\stretch{1}} \Huge} {\marginpar{ \Huge{?} } \newline}
\newenvironment{A} {\hspace{\stretch{1}} \Huge} {\marginpar{ \Huge{!} } \newline}
\begin{document}
\section{First section}
Some text ... Margin note entered {\em here} \marginpar{NOTE} ... more text \\
\vspace{0.5in}
\begin{Q} Here is a question \end{Q}
State your question ... \\
\begin{A} This is an answer \end{A}
Go with the answer ... \\
New paragraph, for other text ...
\end{document}
See this page in Latex Wikibooks for a very clear explanation of how to define a new environment. If you end up wanting more control see the package environ.
Margin notes provide you with a few options. If you want to reverse the logic of where they are placed, use \reversemarginpar. You can also set up different text to appear depending on which margin the note goes in by using \marginpar[left text]{right text}. See the Wikibooks article on footnotes and margin notes, which spells out where notes go based on the document type.
Here are some posts for more specialized uses: on notes in both margins, and on notes in narrow margnins. For doing far more with margin notes see package magrinnote, and there are yet other packages, like todonotes. See this post for a visual show off of what it can do.
I've used a basic way to change font size, and no special symbols. A list of these fonts can be found in this post, for example. You can use very particular fonts and/or symbols if you like, which are convenient to set up in the new environment. See, for example, this post, which also has another way of formatting for your Q&A. Also informative may be this post.
Note that you can also use existing environments inside this new one, if you wish. You can also set up a counter, and have an ability to cross-reference these. See this post for an example.

Exclude entry from glossary?

I'm using the glossaries package in LaTeX. I've got \gls{foo} in my document, but I don't want the entry for "foo" to appear in the glossary. How can I keep a working (i.e. expanding) \gls{foo} in the body of my document, but exclude the entry for "foo" from the glossary?
EDIT: I want to use \gls{foo} to indicate "as used here, 'foo' has its specific meaning within this document." In a few cases, though, I've ended up with a "foo" whose definition is too obvious--or difficult--to articulate in the glossary.
So I want \gls{foo} to be expanded as usual, but I don't want the "foo" entry to appear in the glossary.
I hope this adds a little more information about what I'm trying to accomplish. It may be an abuse of glossaries, but I find it helpful to make sure I'm always using the same words and the right words while writing technical documents.
If you are using the glossaries package you can create an "ignored" glossary like
\documentclass{article}
\usepackage{glossaries}
\newglossary[glignoredl]{ignored}{glignored}{glignoredin}{Ignored Glossary}
\makeglossaries
\newglossaryentry{foofoo}{name={FOOFOO},description={foofoo stuff}}
\newglossaryentry{foo}{name={FOO},type={ignored},description={no good description}}
\newglossaryentry{bar}{name={BAR},description={bar of stuff}}
\begin{document}
Here is a \gls{foo} that is also a \gls{bar}, but of course it's also a \gls{foofoo}.
Why not consider buying a \gls{foo}?
\printglossary
% \printglossary[type={ignored}]
\end{document}
I have no idea why you'd want to do this, but the following should work:
\let\oldgls\gls% store the original meaning of \gls in a new command named \oldgls
\let\gls\relax$ make \gls do nothing
Some text with \gls{foo} no links to the glossary,
and no ``foo'' entry in the glossary.
\let\gls\oldgls% restore the original meaning of \gls
Some more text with \gls{bar} that links to the glossary,
and with a ``bar'' entry in the glossary.
This can be accomplished by adding the terms to a special common dictionary. It's actually a built-in feature of the glossaries package and it's even exemplified by the package author. From said example:
\documentclass{article}
\usepackage{glossaries}
\newignoredglossary{common}
\makeglossaries
\newglossaryentry{sample}{name={sample},description={an example}}
\newglossaryentry{commonex}{type=common,name={common term}}
\begin{document}
\gls{sample}. \gls{commonex}.
\printglossaries
\end{document}
Note the use of the \newignoredglossary command.

glossaries package and footnote in LaTeX

I am currently stuck, having two separate glossaries: main & acronyms. Acronyms glossary prints footnotes on first use in the text, but main glossary does not. Is there any way to make any other glossary than acronyms to print footnote on first use of the term? I don't get how to do it.
Here is the code example compiled with TeXnic Center and MiKTeX 2.7:
\documentclass{article}
\usepackage{index}
\usepackage[toc,style=long3colheaderborder,footnote,acronym]{glossaries}
\makeindex
\makeglossaries
\newglossaryentry{appdomain}{name={application domain}, description={app Domain Description...}}
\newglossaryentry{sample}{name={[has been inserted aaa]},description={testing testing 123}}
\newacronym{aca}{aca}{a contrived acronym}
\begin{document}
\section{this is a test section}
This is the test line... a \gls{sample} \gls{appdomain}
\index{entry} and \gls{aca}
\thispagestyle{empty}\cleardoublepage
\printglossary[type=main,title={Glossary},toctitle={Glossary}]
\thispagestyle{empty}\cleardoublepage
\printglossary[type=\acronymtype,title={List of Abbreviations},toctitle={List of Abbreviations}]
\printindex
\thispagestyle{empty}\cleardoublepage
\end{document}
I want sample and appdomain either contain a footnote with description or a footnote stating: please refer to Glossary
Many thanks,
Ovanes
In short, with the glossaries package, you can't get footnotes on the first use for non-acronym glossaries.
However, you can redefine some commands in the preamble (after you \usepackage{glossaries}) to get what you want:
\makeatletter
\renewcommand{\gls#main#displayfirst}[4]{
#1#4\protect\footnote{#2}
}
\makeatother
But that will be really fragile.
I think there is an easier way of doing this. Maybe it's new, but
\defglsdisplayfirst[main]{#1#4\protect\footnote{#2}}
appears to achieve the exact same thing (correct me if I'm wrong). See the glossaries manual, version 2.03, subsection 2.4.1 changing the format of the text.
Unfortunately, it appears commands like \gls or \autoref does not work in those footnotes.
Following is a good technique, to put a footnote stating where the definitions are:
\label{nom} %put this on the page your term appears, so that it can collect page number
\newcommand{\g}{\footnote{For all abbreviations see the glossary on page \pageref{nom}.}}
I've found this from here.

Three columns frame in a big document and renaming stuff in latex

I'm just learning latex, so this may be trivial to some of you.
I went through a few tutorials but they all seem to cover the same things.
I'm writing a big report - calculation all the way (and it has to be neat, because it's part of the documentation). It consists of a frame around the page (15mm margins), and 3 columns inside it: in the left column (3cm wide) are references from where the equation came from (e.g. "ABS 3-2-7"), in the middle is the calculation and in the right is the accepted value (5cm wide). It is a standard way of doing things, so I don't have a choice over the layout.
Now, I don't understand, how would I go in creating such layout ? The frame with columns has to appear on every page. How to accomplish that ?
I've never seen such a document so I'm not sure how to ease the creation.
And second, how do I rename things that are in english language in document classes ? For example, "article" class, I have "References" and I need to have "Literatura".
Is there a way to rename it without touching .cls file?
For your first problem, look at the longtable package (available at ctan.org if you haven't already got it installed)
The problem with using tabular is it won't work as you want across pages.
As far as the second problem, it will depend on the environment and the document type, but typically you'll have to renew a command.
For example, add to the preamble \renewcommand\refname{Literatura} for the article class to do what you were asking for. If I recall correctly it is bibname for books.
Table design in LaTeX has not been made very easy. I would use tabbing rather than tabular and draw the lines manually to keep things simple. A downside is that you don't get any automatic sizing of the table cells, but since your format is fixed, I would consider it a good thing (i.e., if text overflows, you notice it and get to fix it yourself, and your table doesn't accidentally get stretched into the margins). If you use multiple tables like this in your document, try packaging the commands with \newenvironment.
\documentclass{article}
\usepackage[margin=15mm]{geometry}
\usepackage{amsmath}
\usepackage{calc}
\newlength{\tableheight}
\setlength{\tableheight}{20cm} % how high to draw the lines of the table
\newlength{\rulethickness}
\setlength{\rulethickness}{1pt} % how thick lines to draw
\newcommand{\verticalline}{\smash{\rule[-\tableheight]{\rulethickness}{\tableheight}}}
\newlength{\myindent}
\setlength{\myindent}{3mm} % how much to indent each column
\newlength{\leftcolumn}
\setlength{\leftcolumn}{3cm-\myindent}
\newlength{\midcolumn}
\setlength{\midcolumn}{\textwidth-3cm-5cm-\myindent-\rulethickness}
\newlength{\rightcolumn}
\setlength{\rightcolumn}{5cm-\myindent}
\begin{document}
\begin{tabbing}
% first set the tab stops
\hspace*{\myindent}\=\hspace{\leftcolumn}\=%
\hspace{\myindent}\=\hspace{\midcolumn}\=%
\hspace{\myindent}\=\hspace{\rightcolumn}\=\kill
% then draw the lines
\rule{\textwidth}{\rulethickness}\\[-\baselineskip]
\smash{\rule[-\tableheight]{\textwidth}{\rulethickness}}\\[-\baselineskip]
\verticalline\>\>\verticalline\>\>\verticalline\>\>\verticalline\\
% Now start the table: indent the first column with \>
\>ABS 3--2--7
% ... and each additional column with \>\>
\>\> $\iint_{-\infty,-\infty}^{\infty,\infty} e^{-x^2-y^2}\, dx\,dy$
\>\> 2.507
% End each line with \\, add e.g. [2pt] to get 2pt extra space if required
\\[2pt]
% here's another line:
\>ABS 3--2--8 \>\> $\displaystyle\sum_{k=0}^n k^2$ \>\> $\frac12 n(n+1)$ \\
% etc. Be careful not to overflow the table - there's no automatic check for that.
\end{tabbing}
\newpage % also remember to start a new page after the table
\end{document}
To change the fixed names, see this FAQ, or possibly this one if you are using babel.
In this case you probably want to use the tabular environment to generate the three columns (or as simon notes longtable if your report-thingy runs longer than one page). Something like:
\framebox{
\centering
\begin{tabular}{p{3cm}|p{\specialwidth}|p{5cm}}
Ref 1-0-0 & 1.2345 & 1.2346 \\
Ref 1-0-1 & 2.3456 & 2.3454 \\
...
\end{tabular}
}
You'll note that I've used paragraph formatted columns (the p{<length>} formatting specifiers), and stuck a frame around it with \framebox.
You can either compute \specialwidth by hand, or calculate it:
\newlength{\specialwidth}
\setlength{\specialwidth}{\textwidth}
\addtolength{\specialwidth}{-10cm} % extra room for the seperators...
I can't help you on the internationalization issue...

How do you extend article document class in LaTeX?

I don't really need a lot of changes to the default article document class. All I want is:
redefine page margins (I want them to be the same on all pages, but different from the default values);
use title page;
add more elements on the title page (title, author and date is not enough for me, I want company and company logo to be on the title page as well);
change styles of the sections, subsections and subsubsections (I don't want the numbers to be shown, otherwise - they're good).
Perhaps, there are some packages that could be helpful in this case?
There are a number of packages that can help you achieve the results you're looking for. The packages I've selected below are the ones I like, but there is more than one way to do it.
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{paulius-article}[2009/02/25 v0.1 Paulius' modified article class]
% Passes and class options to the underlying article class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
% Load LaTeX's article class with the `titlepage' option so that \maketitle creates a title page, not just a title block
\LoadClass[titlepage]{article}
% Redefine the page margins
% TODO: Adjust margins to your liking
\RequirePackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
% Remove the numbers from all the headings (\section, \subsection, etc.)
\setcounter{secnumdepth}{-1}
% To modify the heading styles more thoroughly use the titlesec package
%\RequirePackage{titlesec}
% Adjust the title page design
% NOTE: This is the default LaTeX title page -- free free to make it look like whatever you want.
% TODO: Add company name and logo somewhere in here.
\newcommand{\maketitlepage}{%
\null\vfil
\vskip 60\p#
\begin{center}%
{\LARGE \#title \par}%
\vskip 3em%
{\large
\lineskip .75em%
\begin{tabular}[t]{c}%
\#author
\end{tabular}\par}%
\vskip 1.5em%
{\large \#date \par}% % Set date in \large size.
\end{center}\par
\#thanks
\vfil\null%
\end{titlepage}%
}
% This some before-and-after code that surrounds the title page. It shouldn't need to be modified.
% I've pulled out the part the actually typesets the title page and placed it in the \maketitlepage command above.
\renewcommand\maketitle{\begin{titlepage}%
\let\footnotesize\small%
\let\footnoterule\relax%
\let \footnote \thanks%
\maketitlepage%
\setcounter{footnote}{0}%
\global\let\thanks\relax
\global\let\maketitle\relax
\global\let\#thanks\#empty
\global\let\#author\#empty
\global\let\#date\#empty
\global\let\#title\#empty
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\and\relax
}
% TODO: If there are any other article modifications required, add them here.
% That's all, folks!
\endinput
You'll want to read the documentation for the geometry package to adjust the margins. The titlesec package can be used if you want to modify the appearance of the headings (aside from just turning off the numbers).
The titlepage is LaTeX's default title page. You'll need to modify it to add your company name and logo. I've separated out the "stuff to be printed" from all the other code associated with the title page. You should only need to change the \maketitlepage command. In your document, use \maketitle to print the title page.
\documentclass{paulius-article}
\title{My New Document Class}
\author{Paulius}
\usepackage{lipsum}% provides some filler text
\begin{document}
\maketitle% Actually makes a title page
\section{Section Heading}
\subsection{Look no numbers!}
\lipsum[1-10]
\end{document}
Let me know if I missed any of your requirements.
You start with
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{classname}[2009/02/24]
\LoadClass{article}
and add any customizations after that.
UPDATE: I recommend you to read LaTeX2e for class and package writers: PDF, HTML. The examples in Section 3 (The structure of a class or package) should be helpful.
A couple of points that might be interesting:
You can redefine the margins in the header (i.e. before \begin{document}} by reseting the controlling lengths like \setlength{\textwidth}{6.80in}, \setlength{\oddsidemargin}{0.0in} and so on.
\section*{...} will give you un-numbered sections already. Likewise for \subsection* and \subsubsection*. If you do use this trick and also want working references, you might have a look at How do I emit the text content of a reference in LaTeX?.
Have you looked at the titlepage environment?
But perhaps most important, the memoir class may give you all the control you need without any class hacking. Check out the documentation.
Or use Can Berk Güder's suggestion.

Resources