Use \newcommand without the text styles added to it - latex

This is a weird question and I don't know if I was able to formulate it that well.
So, I declare a newcommand somewhere like this:
\newcommand{\examplecommand}{\textbf{\textit{exampletext}}}
It'll be used quite many times this way.
I'm trying to also use it in one place in the document, wanting to format it in a different way (with \textsc{}, and none of the bolding and italicization)
I tried doing stuff like
\textsc{\examplecommand}
But that doesn't work, it still somehow prioritizes the formatting in the command declaration.
How can I use the command without changing the declaration, but with different formatting?
EDIT (MWE):
document.tex
--------------------
\documentclass{book}
\usepackage{fancyhdr}
\usepackage{blindtext}
\newcommand{\booktitle}{} % create it empty at first, so that the files can change it
\newcommand{\textbfit}[1]{\textbf{\textit{#1}}} % combine bold and italic in one
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[RO,RE]{\textsc{\booktitle}}
\renewcommand{\headrulewidth}{2pt}
}
\begin{document}
\pagestyle{plain}
\chapter{example1}
\input{doc1}
\chapter{example2}
\input{doc2}
\chapter{example3}
\input{doc3}
\end{document}
doc1.tex
--------------------
\renewcommand{\booktitle}{\textbfit{``Title 1''}}
\booktitle\ is a very nice book, it's really great, buy it etcetcetc
\blindtext
doc2.tex
--------------------
\renewcommand{\booktitle}{\textbfit{``Title 2''}}
\booktitle\ is a very nice book, it's really great, buy it etcetcetc
\blindtext
doc3.tex
--------------------
\renewcommand{\booktitle}{\textbfit{``Title 3''}}
\booktitle\ is a very nice book, it's really great, buy it etcetcetc
\blindtext
The reason I want to be able to do this:
I have 12 documents that I wrote in a single-document form, and now I wish to make them work both in the single-document form (all of them having a separate .tex file that compiles them as a single document), and a form that puts them all into a large file.
I was using that \booktitle command across all of them, since they are all similar in general structure. And now when I wanted to also convert them into book form, I discovered I can use it to change the top right corner text inside the header (see that the definition of the plain fancypagestyle uses that command inside its fancyhead), but, in there, I want to use it with \textsc
The reason I don't want to change my command is because it means changing it across all of the documents inside, and I was just thinking I could do \textsc{\booktitle} and be done with it

You could temporarily switch off your \textbfit command:
\documentclass{book}
\usepackage{fancyhdr}
\usepackage{blindtext}
\newcommand{\booktitle}{} % create it empty at first, so that the files can change it
\newcommand{\textbfit}[1]{\textbf{\textit{#1}}} % combine bold and italic in one
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[RO,RE]{
\begingroup
\let\textbfit\relax
\textsc{\booktitle}
\endgroup
}
\renewcommand{\headrulewidth}{2pt}
}
\begin{document}
\pagestyle{plain}
\chapter{example1}
\renewcommand{\booktitle}{\textbfit{``Title 1''}}
\booktitle\ is a very nice book, it's really great, buy it etcetcetc
\blindtext
\end{document}

Related

LaTeX change name of \bibliography{} heading (or remove entirely)

I have seen this question asked a few times on here but none of the answers have gotten me exactly what I want. I am using Overleaf to write a LaTeX document and when I make a bibliography (using the natbib library) it automatically makes a heading named "References". Can I remove this heading somehow? I've tried a couple other options but they haven't worked. I've attached a minimal working example below:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage{hyperref}
\begin{document}
Here is a citation \citep{Source}.
\bibliographystyle{apalike}
\bibliography{refs}
\end{document}
Not sure what didn't work with the existing responses - perhaps you could point to them and indicate what you didn't like about the results? Does replacing the \bibliography{refs} with the following help? (BTW, as this is not an Overleaf question, it's just LaTeX, perhaps remove the overleaf tag and reference.)
\begingroup
\renewcommand
\refname{}
\bibliography{refs}
\endgroup

Treating a quote block similarly to a figure in LaTeX?

Been trying to figure out how to achieve this but can only find ways to do it within the figure environment using wrapfig. I'm using the epigraph package to generate the quote style (as in the screenshot). The current behavior is in this screenshot and generated by the code
\subsection{Methods}
\lipsum[1-2]
\epigraph{Models, of course, are never true, but fortunately it is only necessary that they be useful.}{\textcite{Box1979-em}}
However, the below image is how I wish it to look, but unsure how to achieve this?
Without a MWE, I had to make some adjustments; but this appears to work.
\documentclass[11pt,letterpaper]{article}
\usepackage{lipsum}
\usepackage{epigraph}
\usepackage{biblatex}
\usepackage{wrapfig}
\begin{document}
\setcounter{section}{2}
\subsection{Methods}
\begin{wrapfigure}{r}{0pt}%
\begin{minipage}{0.43\linewidth} % manual adjustment required
\epigraph{Models, of course, are never true, but fortunately it is only necessary that they be useful.}{Box (1979)}
\end{minipage}
\end{wrapfigure}
\lipsum[1-2]
\end{document}

LATEX: delete the number of page from the backmatter

im tring to delete the page number from my \backmatter sequence. I've succeded to do this, writing this code:
\begin{document}
.
.
.
\backmatter
\begingroup
\makeatletter
\let\ps#plain\ps#empty
\addcontentsline{toc}{chapter}{Allegati}
\input{Allegati}
\input{Bibliografia}
\listoffigures
\listoftables
\listof{grafico}{Elenco dei grafici}
\endgroup
\end{document}
But, I don't know why, the last page of my document still have his number. In the code above the last page is a graphic list, but if I change the order of my sequence, for example putting the bibliography in the last position, the this element will present the page number. I'm writing this document using the book class.
Someone can help me?
thanks
As you did not provide a MWE (Minimal Working Example) I can just guess what your document's preamble contains.
Have a look at this code please:
\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{plain}{
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{}
}
\begin{document}
text
\newpage
text
\newpage
\backmatter
\begingroup
\pagestyle{plain}
\addcontentsline{toc}{chapter}{Allegati}
\listoffigures
\listoftables
%\listof{grafico}{Elenco dei grafici}
\endgroup
\end{document}
EDIT1:
This way you redefine the plain-style that is used by every chapter-page in your document.
If you do not want to change it document-wide, your approach is correct; just add a \clearpage before the last \endgroup. It won't create a new page, but delete the pagenumber. Btw, if you don't really need the \begingroup \endgroup leave it out, this will also delete the last page number.
END-EDIT1
A few things to note:
If you use plain book-class, you can use fancyhdr for setting a
page style like in the above example. Later just load the wanted
pagestyle and from there on it will be used.
If you want to write a document according to the modern
standard of LaTeX, maybe think about using a KOMA-class, which
provides great functions for changing the page style (and often they
also work better ;))
For me this MWE does work, having no pagenumber on the last page; if it does not for you, please give us more information about your document.

Extracting code from beamer presentation?

Some years ago I created a Beamer presentation (using only basic features). Unfortunetaly, I've lost the source code but still have the output PDF. Is there a convenient way to extract the original code from the presentation? Simple copy methods does not handle the mathematics well.
No, I don't think it is possible to do that. LaTeX is a typesetting language, in which you say "put a section here, this text here, some formulae here, etc., and use this style file to weight the fonts and spacing" and then compile it to PDF. The PDF document tells the PDF viewer (loosely speaking): "here's the font, place these sets of characters at these places in the document". It has no notion of section/heading/figure/equation/equation number etc.
It would be very hard to do PDF->LaTeX because of the multiple possibilities. i.e., LaTeX->PDF is a many-to-one function, so the inverse operation is going to have ambiguities.
For e.g., here's a test file using two different methods:
\documentclass{article}
\begin{document}
This is a StackOverflow test file.
\section{Method A}
\begin{equation}
ax^2+bx+c=0
\end{equation}
\end{document}
\documentclass{article}
\begin{document}
This is a StackOverflow test file.\\[0.1in]
\noindent {\Large \textbf{1\quad Method B}}
\begin{center}
$\displaystyle ax^2+bx+c=0$
\end{center}
\vspace{-0.25in}
\hfill{(1)}
\end{document}
You can see that you can't tell the two documents apart. A PDF to LaTeX converter will face the same problems.
That said, some word processing applications (open office?) can interpret PDF documents (usually only if all text) and convert it to a word document, and then you can convert that into LaTeX (usually provided by the same application). This might be one option worth trying. Other than that, there is no software that I know of that will do this for you.

Latex template for quickly writing summaries of courses

For some courses I take, we are allowed to write a summary and to used it at the exam. The summary allowed is usually limited to something like ten A4 pages. I quickly googled for latex templatex, but I couldn't find anything useful so far.
The template should allow to used the full space available on an A4 paper, by default latex documents usually have large borders. I guess I'm not the first person looking for this kind of template, so please post any links if you know good templates.
You can setup your margins pretty easily using the geometry package (which should be part of most latex distributions I believe) http://ctan.org/tex-archive/macros/latex/contrib/geometry/
You'll probably also need one of the multiple column layouts and amsmath packages.
You can find a bunch of details on page layout here: http://en.wikibooks.org/wiki/LaTeX/Page_Layout
I'd probably use something like this:
\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{amsmath}
\usepackage{multicol}
\begin{document}
\begin{multicols}{3}
... MY STUFF HERE ...
\end{multicols}
\end{document}
EDIT: Original version was trying to use the plain style, which seems to not exist. Also had the usepackages inside the document rather than the preamble, and had some spelling mistakes. Won't look useful until you fill it with some stub data... head over to lipsum.com for some filler text.

Resources